tree checksum vpatch file split hunks

all signers: diana_coman

antecedents: eucrypt_ch10_oaep_tmsr

press order:

eucrypt_genesisdiana_coman
eucrypt_ch6_keccak_permutationsdiana_coman
eucrypt_ch7_keccak_spongediana_coman
eucrypt_ch9_keccak_endiannessdiana_coman
eucrypt_ch10_oaep_tmsrdiana_coman
eucrypt_oaep_fix_checksdiana_coman

patch:

- 399C9451D688077B5F5701C05032A4F39B0CF3FAE9CB841123F23680C0C2D2DCE5BA5E1F7322B9158642380D1F9EF948A44F7A425DE699965D8706323883CFF7
+ 6F76C1A956F79131D310EC0AC023F10FEBD27376C54D01332EE47B623904816F6469E483B575B86A8F0B568EE224E9812A8FF3D665D891512D2C8BFA3124BAC4
eucrypt/smg_keccak/smg_oaep.adb
(83 . 7)(83 . 7)
5 -- 5. Result is X || Y
6 -- NB: the Entropy parameter should be random octets from which this method
7 -- will use as many as required for the OAEP encryption of given Msg
8 -- NB: at MOST OAEP_LENGTH_OCTETS - 11 octets of Msg! (Msg at most 1960 bits)
9 -- NB: at MOST MAX_LEN_MSG octets of Msg! (Msg at most 1960 bits)
10 procedure OAEP_Encrypt( Msg : in String;
11 Entropy : in OAEP_Block;
12 Output : out OAEP_Block) is
(94 . 19)(94 . 16)
14 HashX : OAEP_HALF;
15 Y : OAEP_HALF;
16 MsgLen : Natural;
17 MaxLen : Natural;
18 PadLen : Natural;
19 TMSR : constant String := "TMSR-RSA";
20 begin
21 -- calculate maximum length of msg and needed amount of padding
22 -- make sure also that only MaxLen octets at most are used from Msg
23 MaxLen := OAEP_HALF_OCTETS - TMSR'Length - 3; -- maximum msg that fits
24 -- make sure also that only MAX_LEN_MSG octets at most are used from Msg
25 MsgLen := Msg'Length; -- real msg length
26 if MsgLen > MaxLen then
27 MsgLen := MaxLen; --only first MaxLen octets will be considered
28 PadLen := 0; --no padding needed
29 if MsgLen > MAX_LEN_MSG then
30 MsgLen := MAX_LEN_MSG; --only first MAX_LEN_MSG octets are considered
31 PadLen := 0; --no padding needed
32 else
33 PadLen := MaxLen - MsgLen; -- msg is potentially too short, add padding
34 PadLen := MAX_LEN_MSG - MsgLen; -- msg may be too short, add padding
35 end if;
36
37 -- step 1: header and format to obtain M00
(155 . 7)(152 . 6)
39 Success : out Boolean ) is
40 X, Y, M, R : OAEP_HALF;
41 HashX, HashR : OAEP_HALF;
42 MaxLen : constant Natural := OAEP_LENGTH_OCTETS - 11;
43 LenOctets : Natural;
44 begin
45 -- step 1: separate X and Y
(175 . 7)(171 . 7)
47 Character'Pos( M( M'First + 2 ) );
48 LenOctets := Len / 8;
49
50 if LenOctets > MaxLen or LenOctets < 0 then
51 if LenOctets > MAX_LEN_MSG or LenOctets < 0 then
52 Success := False; -- error, failed to retrieve message
53 else
54 Success := True;
- ED6FC57F63DEF71E7C286F1E9115264412611AD19E925CB0EDE29C3BDA6CD40F6F63CCE6CDC9ECC2C7F55E555292D7EBA058FBCF4C9A49AF24CAB43B8345F253
+ 64E606C3F54EE3585735C6B2050A7C2262AF782632635616EB363A9DD6A48E4C43AFEAD5370DA655644B4194E2F974D936AF97F4425C568EC382E23D747D40F3
eucrypt/smg_keccak/smg_oaep.ads
(13 . 6)(13 . 8)
59 OAEP_LENGTH_BITS : constant := 4096;
60 OAEP_LENGTH_OCTETS : constant := 512;
61 OAEP_HALF_OCTETS : constant := OAEP_LENGTH_OCTETS / 2;
62 TMSR : constant String := "TMSR-RSA";
63 MAX_LEN_MSG : constant := OAEP_HALF_OCTETS - TMSR'Length - 3;
64
65 -- subtypes used by the OAEP encrypt/decrypt
66 subtype OAEP_Block is String( 1 .. OAEP_LENGTH_OCTETS );
(29 . 7)(31 . 7)
68 -- 5. Result is X || Y
69 -- NB: the Entropy parameter should be random octets from which this method
70 -- will use as many as required for the OAEP encryption of given Msg
71 -- NB: at MOST OAEP_LENGTH_OCTETS - 11 octets of Msg! (Msg at most 1960 bits)
72 -- NB: at MOST MAX_LEN_MSG octets of Msg! (Msg at most 1960 bits)
73 procedure OAEP_Encrypt( Msg : in String;
74 Entropy : in OAEP_Block;
75 Output : out OAEP_Block);
- B9DD611C05352BC2DCD237EE59409CBBABF02068D8639CBDE73B6F273EA1480BB9C40CAB85F83FD7D56CE6CD59BBBE42F171CE90BD1AAAD265109B745FABB808
+ D32B0AD7D28C2641A7172DD10F409670EB9D6A925A755FAAAEED545123ABF45DB6B30BAD662C88B1428A656876154C2C5091FCCF82B4924F1863B9A6B9AD2537
eucrypt/smg_keccak/tests/smg_keccak-test.adb
(354 . 7)(354 . 6)
80 begin
81 Put_Line("----Testing hash keccak on string " & S & "----");
82 HashKeccak(S, O);
83 Put_Line("OUTPUT: " & O);
84 ToBitstream( O, B );
85 if B /= Exp then
86 Put_Line("FAILED: testing hash keccak on string");
(387 . 7)(386 . 6)
88 XOR_Strings( S1, S2, Result);
89 Put_Line("S1 is " & S1);
90 Put_Line("S2 is " & S2);
91 Put_Line("S1 xor S2 is " & Result);
92 Put_Line("Result is: ");
93 for C of Result loop
94 Put( Natural'Image( Character'Pos( C ) ) );
(403 . 11)(401 . 14)
96
97 procedure test_oaep is
98 Msg : String := "abcdefghij jihgfedcba123456789";
99 LongMsg : String( 1..1000 ) := ( others => 'T' );
100 Encr : OAEP_Block := ( others => ' ' );
101 Decr : OAEP_HALF := ( others => ' ' );
102 Entropy : OAEP_Block := ( others => 'e' );
103 Len : Natural;
104 Flag : Boolean;
105 C : Character;
106 MaxLen : constant := 245;
107 begin
108 Put_Line("----Testing OAEP Encrypt----");
109 OAEP_Encrypt( Msg, Entropy, Encr );
(415 . 21)(416 . 54)
111 Put_Line("----Testing OAEP Decrypt----");
112 OAEP_Decrypt( Encr, Len, Decr, Flag );
113
114 Put_Line("Msg is: " & Msg);
115 Put_Line("Encr is: " & Encr);
116 Put_Line("Decr is: " & Decr);
117 Put_Line("Flag is: " & Boolean'Image( Flag ) );
118 Put_Line("Len is: " & Natural'Image( Len ) );
119
120 if Flag = False or
121 Len /= Msg'Length * 8 or
122 Decr( Decr'First .. Decr'First + Msg'Length - 1 ) /= Msg
123 then
124 Put_Line("FAILED: oaep test");
125 Put_Line("Msg is: " & Msg);
126 Put_Line("Decr is: " & Decr);
127 Put_Line("Flag is: " & Boolean'Image( Flag ) );
128 Put_Line("Len is: " & Natural'Image( Len ) );
129 else
130 Put_Line("PASSED: oaep test");
131 end if;
132
133 -- test decrypt on invalid (non-OAEP) string
134 Flag := True;
135 C := Encr( Encr'First );
136 Encr( Encr'First ) := Character'Val( Character'Pos( C ) / 2 );
137 Decr := ( others => ' ' );
138 OAEP_Decrypt( Encr, Len, Decr, Flag );
139
140 if Flag = True then
141 Put_Line("FAILED: oaep test with invalid package");
142 else
143 Put_Line("PASSED: oaep test with invalid package");
144 end if;
145
146 -- test encrypt on message longer than maximum payload (1096 bits)
147 Flag := False;
148 Len := 0;
149 LongMsg( 1..Msg'Length ) := Msg;
150 Encr := ( others => '.' );
151 OAEP_Encrypt( LongMsg, Entropy, Encr);
152 OAEP_Decrypt( Encr, Len, Decr, Flag);
153
154 if Flag = False or
155 Len /= MaxLen * 8 or
156 Decr( Decr'First .. Decr'First + Len / 8 - 1 ) /=
157 LongMsg( LongMsg'First..LongMsg'First + MaxLen - 1 )
158 then
159 Put_Line("FAILED: oaep test with too long message");
160 Put_Line("Msg is: " & LongMsg);
161 Put_Line("Decr is: " & Decr);
162 Put_Line("Flag is: " & Boolean'Image( Flag ) );
163 Put_Line("Len is: " & Natural'Image( Len ) );
164 else
165 Put_Line("PASSED: oaep test with too long message");
166 end if;
167
168 end test_oaep;
169
170 -- end of helper methods