- 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;