Source file : zip-crc_crypto.ads
1 -- Zip.CRC_Crypto deals with hash-like functions
2 -- for data integrity check and encryption
3 -------------------------------------------------
4
5 -- Legal licensing note:
6
7 -- Copyright (c) 1999 .. 2024 Gautier de Montmollin
8 -- SWITZERLAND
9
10 -- Permission is hereby granted, free of charge, to any person obtaining a copy
11 -- of this software and associated documentation files (the "Software"), to deal
12 -- in the Software without restriction, including without limitation the rights
13 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 -- copies of the Software, and to permit persons to whom the Software is
15 -- furnished to do so, subject to the following conditions:
16
17 -- The above copyright notice and this permission notice shall be included in
18 -- all copies or substantial portions of the Software.
19
20 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 -- THE SOFTWARE.
27
28 -- NB: this is the MIT License, as found on the site
29 -- http://www.opensource.org/licenses/mit-license.php
30
31 package Zip.CRC_Crypto is
32
33 use Interfaces;
34
35 -------------------------------------------------------------
36 -- CRC: Cyclic Redundancy Check to verify data integrity --
37 -------------------------------------------------------------
38
39 procedure Init (CRC : out Unsigned_32);
40
41 procedure Update (CRC : in out Unsigned_32; InBuf : Zip.Byte_Buffer);
42 pragma Inline (Update);
43
44 function Final (CRC : Unsigned_32) return Unsigned_32;
45 pragma Inline (Final);
46
47 ------------------
48 -- Encryption --
49 ------------------
50
51 type Crypto_pack is private;
52 --
53 type Crypto_Mode is (clear, encrypted);
54 procedure Set_Mode (obj : in out Crypto_pack; new_mode : Crypto_Mode);
55 function Get_Mode (obj : Crypto_pack) return Crypto_Mode;
56 --
57 procedure Init_Keys (obj : in out Crypto_pack; password : String);
58 --
59 procedure Encode (obj : in out Crypto_pack; buf : in out Zip.Byte_Buffer);
60 pragma Inline (Encode);
61 --
62 procedure Decode (obj : in out Crypto_pack; b : in out Unsigned_8);
63 pragma Inline (Decode);
64
65 private
66 type Decrypt_Keys is array (0 .. 2) of Unsigned_32;
67 type Crypto_Pack is record
68 keys : Decrypt_Keys;
69 current_mode : Crypto_Mode;
70 end record;
71
72 end Zip.CRC_Crypto;
Web view of Ada source code generated by GNATHTML, project: ALI_Parse version 1.0.
Zip-Ada: Ada library for zip archive files (.zip).
Ada programming.
Some news about Zip-Ada and other Ada projects
on Gautier's blog.