diff -uNr a/smg_comms/manifest b/smg_comms/manifest --- a/smg_comms/manifest 094d9668c13448f4869ab21bf0779d36675d26fa4648585bd73e9a661aa0f936dd440d9b2dd523d8d363c143fc4f6f9b4bbb20f4f7f7c05067b4f3992d3b7461 +++ b/smg_comms/manifest 093be13909ee7cd2a1a381c45a35e93ce3d7491987adf948ff44e5d94e201ce78410d6cb72b67b046979e45aaa6b20ee05079f30a922467ed6bd7f76f28217e1 @@ -3,3 +3,4 @@ 546152 smg_comms_packing_serpent diana_coman Packing/Unpacking Serpent messages <-> Serpent packets. Includes Serpent implementation. 547275 smg_comms_c_wrappers diana_coman C wrappers for RSA and MPI methods that are needed by SMG Comms (so that they can be called from Ada using only arrays of octets as inputs/outputs). 547983 smg_comms_rsa_oaep diana_coman RSA with OAEP from ADA using the c_wrappers for RSA only. It includes reading from FG in Ada and repeat of OAEP until first octet is < first octet of key's modulus (i.e. without going through MPI for comparison). +548433 smg_comms_packing_rsa diana_coman Packing/Unpacking RSA messages <-> RSA packets of Eulora's communication protocol. diff -uNr a/smg_comms/src/keccak.adb b/smg_comms/src/keccak.adb --- a/smg_comms/src/keccak.adb 53945ea441af37b53c009c3b31826bb688cba5525176d55ed76b934fa34702a86e31041cf4d125fa9fc827c41c242a06e472a0ad2d80fb33dda9f9ab08260458 +++ b/smg_comms/src/keccak.adb 294ba38d9e97be1b0f63d96ba294ef5628cee71001c683024322ca7f7dc086a885bc91ded97d96cac045daa944f535dda3775b36cf8b017f693f31bde1994775 @@ -218,6 +218,9 @@ Y := 0; for T in 0..23 loop + -- NB: the mod op forces an implicit conditional (check against div 0) + -- If No_Implicit_Conditionals restriction is desired, + -- replace mod Z_Length with and (Z_Length - 1 ) Output(X, Y) := Rotate_Left(Input(X,Y), ((T+1)*(T+2)/2) mod Z_Length); Old_Y := Y; Y := 2*X + 3*Y; diff -uNr a/smg_comms/src/oaep.adb b/smg_comms/src/oaep.adb --- a/smg_comms/src/oaep.adb 982b3d71f5ae114abc3a8a5c754e0f645d62694bedef479dec7d51ddc454ac23f19edf27526b2f1a5d91a73ee0111c2761c29551e5c6894d4844660e2981717c +++ b/smg_comms/src/oaep.adb efeaaa4c7dfd3875bd71a32327e798aaac33550e1205f0e929dd0b6ed66a46dfa2d4546b2281b5e6ff67c495acb13b86f74c5ff7c0adba628bdc58c74344d159 @@ -45,7 +45,7 @@ M00( M00'First + 1) := Unsigned_8( ( (MsgLen * 8 ) / 256 ) mod 256 ); -- next 8 octets are reserved for later use, currently "TMSR-RSA" - M00( M00'First + 3 .. M00'First + 10 ) := TMSR; + M00( M00'First + 3 .. M00'First + 10 ) := Raw_Types.OAEP_RESERVED; -- random bits for padding, if Msg is less than maximum length for I in 1 .. PadLen loop diff -uNr a/smg_comms/src/oaep.ads b/smg_comms/src/oaep.ads --- a/smg_comms/src/oaep.ads c4d51b3d41ca323c78b1c7a591b002a59fc756a1d895041dd2d3ddf4f2f2fcb60714c65e6a338949d8ce2ac5ef2bcccb1365c97842e013849707cefa4e633a4b +++ b/smg_comms/src/oaep.ads 1df6e427d9a484501633259ac37ae404cabd5a7513447ca85daf349da205d5f70dedb59486d1a868561a22ffc02d5e70cb05198c412e7beef7f926a5cf6a8a21 @@ -15,11 +15,9 @@ OAEP_LENGTH_OCTETS : constant := Raw_Types.RSA_KEY_OCTETS; OAEP_LENGTH_BITS : constant := OAEP_LENGTH_OCTETS * 8; OAEP_HALF_OCTETS : constant := OAEP_LENGTH_OCTETS / 2; - TMSR_STR : constant String := "TMSR-RSA"; + TMSR_STR : constant String := Raw_Types.OAEP_R_STR; -- "TMSR-RSA" as unsigned_8 values: - TMSR : constant Raw_Types.Octets := (84,77,83,82,45,82,83,65); - MAX_LEN_MSG : constant Natural := OAEP_HALF_OCTETS - - TMSR_STR'Length - 3; + MAX_LEN_MSG : constant := Raw_Types.OAEP_MAX_LEN; -- subtypes for OAEP encrypt/decrypt subtype OAEP_Block is Raw_Types.Octets( 1 .. OAEP_LENGTH_OCTETS ); diff -uNr a/smg_comms/src/packing.adb b/smg_comms/src/packing.adb --- a/smg_comms/src/packing.adb 9650f68c8bfba99299b059e943008ce5c682b3991e60ea7ee51c22f23373b56a9c1bd1c6459f5d7f8a5553244a4656c357035cf54caecac4cbcab25041b2c011 +++ b/smg_comms/src/packing.adb 35a028de1f46c6b81db6159697df6a2cd170acadf60cbb5ca01880206bf59b34d6f9fe8199b77120fc680d882bcc2dec0d21ee552fe76af5686cbc02a418397c @@ -74,4 +74,86 @@ return Msg; end Unpack; + -- Packing a RSA message into RSA packet, using the given key + function Pack( Msg : in Raw_Types.RSA_Msg; + K : in RSA_OAEP.RSA_pkey) + return Raw_Types.RSA_Pkt is + + -- a chunk that can be processed via rsa+oaep at any given time + Chunk: Raw_Types.Octets(1..Raw_Types.OAEP_MAX_LEN) := (others => 0); + + -- number of chunks in the message to process + -- NO incomplete chunks will be processed! + -- NB: values are set so that there are no incomplete blocks here + N : constant Natural := Msg'Length / Chunk'Length; + + -- intermediate result, as obtained from rsa_oaep + Encr: Raw_Types.RSA_len := (others => 0); + + -- final resulting RSA Packet + Pkt : Raw_Types.RSA_Pkt := (others => 0); + begin + -- there should ALWAYS be precisely N chunks in Msg to feed to rsa_oaep + -- process chunks of Msg one at a time + for I in 1..N loop + -- get current chunk + Chunk := Msg(Msg'First + (I-1) * Chunk'Length .. + Msg'First + I * Chunk'Length - 1 ); + -- call rsa oaep encrypt on current chunk + RSA_OAEP.Encrypt( Chunk, K, Encr ); + -- copy result to its place in final packet + Pkt( Pkt'First + (I-1) * Encr'Length .. + Pkt'First + I * Encr'Length - 1 ) := Encr; + end loop; + -- return final result + return Pkt; + end Pack; + + -- Unpacking a RSA packet into contained message, using the given key + function Unpack( Pkt : in Raw_Types.RSA_Pkt; + K : in RSA_OAEP.RSA_skey; + Success : out Boolean) + return Raw_Types.RSA_Msg is + -- a chunk - basically input for RSA_OAEP.Decrypt + Chunk : Raw_Types.RSA_len := (others => 0); + + -- intermediate result of rsa_oaep decrypt + Decr : Raw_Types.Octets( 1..Raw_Types.OAEP_MAX_LEN ) := (others => 0); + Len : Natural; + Flag : Boolean; + + -- number of chunks in the packet + -- NB: there should be only FULL chunks! otherwise -> fail + N : constant Natural := Pkt'Length / Chunk'Length; + + -- final resulting message content of the given RSA packet + Msg : Raw_Types.RSA_Msg := (others => 0); + begin + -- initialize Success flag + Success := True; + + -- process given packet, chunk by chunk + for I in 1..N loop + -- get current chunk + Chunk := Pkt( Pkt'First + (I-1) * Chunk'Length .. + Pkt'First + I * Chunk'Length - 1 ); + -- decrypt it via rsa+oaep + RSA_OAEP.Decrypt( Chunk, K, Decr, Len, Flag ); + -- check result and if ok then copy it to final result at its place + -- NB: if returned length is EVER less than OAEP_MAX_LEN then -> fail! + -- the reason for above: there will be undefined bits in the output! + if Len /= Raw_Types.OAEP_MAX_LEN or (not Flag) then + Success := False; + return Msg; + else + Msg( Msg'First + (I-1) * Decr'Length .. + Msg'First + I * Decr'Length - 1 ) := Decr; + end if; + end loop; + + -- return obtained message + return Msg; + end Unpack; + + end Packing; diff -uNr a/smg_comms/src/packing.ads b/smg_comms/src/packing.ads --- a/smg_comms/src/packing.ads ad406f2a69515e600b7b4986232eb5ad88c0a058f3cdb24981044389a88a5a30c92f198b5431f59d38149ab99e8c893fe6657a7d940f51ea4b28ed0d113c46d0 +++ b/smg_comms/src/packing.ads 1abd8b4c0b1dc937f181a72c6be60886d6739239fed88204046d674c1f63206d37f338fd055f16da09ff9eedf2ec4da6e8fb19d63683737aece44c0498e72e60 @@ -5,21 +5,33 @@ with Raw_Types; with Serpent; +with RSA_OAEP; package Packing is - -- no side effects or internal state - Pragma Pure(Packing); + -- no side effects or internal state BUT it depends on non-pure: + -- rsa_oaep because it uses rng (exceptions and sequential_io) - -- Packing a Serpent message into Serpent package, using the given key + -- Packing a Serpent message into Serpent packet, using the given key function Pack( Msg : in Raw_Types.Serpent_Msg; - K : in Serpent.Key ) - return Raw_Types.Serpent_Pkt; + K : in Serpent.Key ) + return Raw_Types.Serpent_Pkt; -- Unpacking a Serpent packet into contained message, using the given key function Unpack( Pkt : in Raw_Types.Serpent_Pkt; - K : in Serpent.Key) + K : in Serpent.Key) return Raw_Types.Serpent_Msg; + -- Packing a RSA message into RSA packet, using the given key + function Pack( Msg : in Raw_Types.RSA_Msg; + K : in RSA_OAEP.RSA_pkey) + return Raw_Types.RSA_Pkt; + + -- Unpacking a RSA packet into contained message, using the given key + function Unpack( Pkt : in Raw_Types.RSA_Pkt; + K : in RSA_OAEP.RSA_skey; + Success : out Boolean) + return Raw_Types.RSA_Msg; + -- internals of this package, NOT for outside use private -- length of 1 Serpent block diff -uNr a/smg_comms/src/raw_types.ads b/smg_comms/src/raw_types.ads --- a/smg_comms/src/raw_types.ads 86acc0069ca2466f40782bd7c7643b97b465d520fcac61479a7e401fd1a2fc9a8d51360d94aad997a3e91265bd98555bfcc5a8453ad0ca352f0e2300729e0c52 +++ b/smg_comms/src/raw_types.ads af8d8aef6af31a1e9b664ed49aa62785576de0526849596269ec46ede622c474756fb58ac151a26c93484913881afdedd3a069d4327cbc741d6f0c62fed9238d @@ -12,6 +12,10 @@ -- no side effects or internal state Pragma Pure(Raw_Types); + -- raw, low-level type + -- all messages and packets are simply arrays of octets at low level/raw + type Octets is array( Natural range <> ) of Interfaces.Unsigned_8; + -- constants from SMG.COMMS standard specification -- RSA key size in octets @@ -21,22 +25,29 @@ -- a. it's C code that should import this, not the other way around. -- b. it needs to be static here. RSA_KEY_OCTETS : constant Positive := 490; + + -- OAEP constants: defined here as still part of standard spec. + -- OAEP package will use those values when using Raw_Types + -- (NOT the other way around since dependency is oaep on types.) + OAEP_R_STR : constant String := "TMSR-RSA"; + -- "TMSR-RSA" as unsigned_8 values: + OAEP_RESERVED : constant Octets := (84,77,83,82,45,82,83,65); + -- max length of useful payload in a OAEP-encrypted entity + OAEP_MAX_LEN : constant Natural := RSA_KEY_OCTETS / 2 - + OAEP_R_STR'Length - 3; + -- size of a RSA-encrypted packet and message in octets and bits + RSA_PKT_OCTETS : constant Positive := 1470; + RSA_MSG_OCTETS : constant Positive := RSA_PKT_OCTETS / + RSA_KEY_OCTETS * + OAEP_MAX_LEN; + RSA_MSG_BITS : constant Positive := RSA_MSG_OCTETS * 8; -- size of a serpent-encrypted packet and message, in octets -- note that this corresponds to 1472/16 = 92 Serpent blocks -- NB: lengths are the same! SERPENT_OCTETS : constant Positive := 1472; - -- size of a RSA-encrypted packet and message in octets and bits - RSA_PKT_OCTETS : constant Positive := 1470; - RSA_MSG_OCTETS : constant Positive := 234; - RSA_MSG_BITS : constant Positive := RSA_MSG_OCTETS * 8; --1872 - - -- raw, low-level types - -- all messages and packets are simply arrays of octets at low level/raw - type Octets is array( Natural range <> ) of Interfaces.Unsigned_8; - -- raw representations of basic types (with fixed, well-defined sizes) subtype Octets_1 is Octets( 1 .. 1 ); subtype Octets_2 is Octets( 1 .. 2 ); diff -uNr a/smg_comms/tests/test_packing.adb b/smg_comms/tests/test_packing.adb --- a/smg_comms/tests/test_packing.adb 27bbb5c117f46558f9f220e460e66c340d340e1d5315ec372b6c7765d709b22e56277a21712643cbcf8db468752f5a22a7e9d832150a4b32b1c343b69ed24b20 +++ b/smg_comms/tests/test_packing.adb aa23a7dca5d7db80c185ab5c81d4e3645d3a32ce795559dc6c057806ba4928d1c56b0528fc45578dfb0ae69152b290abc591eb86931b59e1a862adf7ad480ae5 @@ -3,7 +3,9 @@ with Packing; use Packing; with Raw_Types; use Raw_Types; +with RSA_OAEP; use RSA_OAEP; with Serpent; use Serpent; +with RNG; use RNG; with Interfaces; use Interfaces; with Ada.Text_IO; use Ada.Text_IO; @@ -19,7 +21,7 @@ New_Line; end Print; - procedure Test_Pack_Unpack is + procedure Test_Pack_Unpack_Serpent is InMsg : Serpent_Msg := (others => 0); OutMsg : Serpent_Msg := (others => 0); @@ -50,6 +52,7 @@ Plain := InMsg((J-1)*Block'Length + 1 .. J*Block'Length); Serpent.Encrypt(KS, Plain, Encr); if Encr /= OutPkt((J-1)*Block'Length + 1 .. J*Block'Length) then + Put_Line("FAIL: pack/unpack with Serpent."); raise Test_Error; end if; end loop; @@ -57,7 +60,73 @@ -- iterate, re-packing as "message" the previous package InMsg := OutPkt; end loop; - - end Test_Pack_Unpack; + + Put_Line("PASS: test pack/unpack with Serpent."); + end Test_Pack_Unpack_Serpent; + + procedure Test_Pack_Unpack_RSA is + Msg : RSA_Msg; + Decr_Msg : RSA_Msg; + PKey : RSA_pkey; + SKey : RSA_skey; + Success : Boolean; + Pkt : RSA_Pkt; + n: String := "C6579F8646180EED0DC1F02E0DDD2B43EABB3F702D79D9928E2CDA5E1D42DF5D9ED7773F80B1F8D9B0DB7D4D00F55647640D70768F63D3CED56A39C681D08D6191F318BB79DC969B470A7364D53335C8318EF35E39D5DF706AB6F2393C6DD2128C142DBAB1806EB35E26C908F0A48419313D2D0F33DD430655DBFEC722899EC21C238E8DB7003430BBC39BAD990F9887F6B03E1344F537EC97389B78DBC656718ACD7B0FDC13DD24534F417BC7A18F077A0C4227354CEA19670331B6CAA3DFC17BBA7E70C14510D9EB3B63F3014994EC87BD23E868C0AE6E9EC55027577F62C0280B2D7DD1135001844923E5455C4566E066B3FDE968C6BC4DC672F229FCE366440403D7A4F4A8BFBA5679B7D0844BA1231277D13A77C9E2B5A1CB138C1B7AB5B4D4832448723A3DE70ED2E86D5FC5174F949A02DE8E404304BEB95F9BF40F3AA3CA15622D2776294BE7E19233406FF563CB8C25A1CB5AADBC1899DA3F2AE38533931FE032EE3232C2CD4F219FADF95B91635C0762A476A4DE5013F4384093F0FB715028D97F93B2E6F057B99EE344D83ADF2686FD5C9C793928BEF3182E568C4339C36C744C8E9CA7D4B9A16AA039CBF6F38CC97B12D87644E94C9DBD6BC93A93A03ED61ECC5874586E3A310E958F858735E30019D345C62E5127B80652C8A970A14B31F03B3A157CD5"; + e: String := "F74D78E382FC19B064411C6C20E0FDB2985F843007A54C7D8400BB459468624126E7D175F397E55C57AF25858EAE2D2952FB7998C119A6103606733EB5E1D27FCA1FACF14ADE94101D383D1B25DA511805569BC344EAD384EDBF3F3A541B34887FE199D99D7F62E6E9D516F88D6F5AD3E020DF04D402A02CC628A0064362FE8516CF7CD6040E9521407AB90EE6B5AFFF9EA9EBB16A7D3407CE81FD3844F519880556AB94AB349C1F3BBB6FDB4C4B377FE4C091EBDC2C3A1BD3AA56382D8D80E7742B5C751008FD6ECDD2EC3B2E3B6C566F698ED672000B403766DD63C3ACBDE16A14FB02E83A2EB6AA018BFC0020401E790DEE24E9"; + d: String := "698DA05DA25B230211EEF0CBA12083A1457B749A11937AC9993859F69A3BF38D575E5166AF2EC88D77F1DF04E68AEA358EACF7659FD4722A4F5A1C8BA7676DA97A9FBA75451152F8F68887D3451A9CCFFFE9EB80979786E37495B17687A6212F77FA616E4C0CD8A8EB7AEB88EA6CCABB7F3E854FB94B35394A09F95F0D6F997947E865CC0606F437C30FE8C48D96FBF5E2F52807BC9E9ED7BBEB23D5C45EDDCD16FE2BF410A9A1E5EF879E71C0D41FAE270C0C5D442860103F8C3944E802F33DB38432F11F763A7AF593656108E4A98A44A8549913CE5DCEC1A6500F280E3190991B2B938561CFACD8BC5183AAC9A4914BFE52C3BE39BB83688E1DE52479107EF8E087DCDB409432FC954C6349407E81DDFB11AE92BABB32A31868597958C9C76E0B4156F380955F0E09C1F3B98BB4CDD59E1B5C7D8CC2AA7491B0D319D219CF459A527CE1AA2729DEC53269653BF0ED3E0253F4451168437E3B069E48350CA4C3EC82134E87135624C768D1330B0D70C6E447FD9945BF06FCB91AA334C0FD8EEF1ADBC15928B3DB62077B537F7E9F468CC95CD5AAFEAE1F760A863B48D07B163F670E2E5B550BB3E960230BA9FDAED9903AE2E669A7F3C4D1F1E25B8E8EDB8CC6E6FD2164E66F4E64ED77BEF1EC9E6CEA5624FD84C0680248746DC1C8187145F3CD2411659DAEAD11D"; + p: String := "CDD6F7673A501FB24C44D56CA1D434F6CB3334E193E02F8E906241906BCB7412DD2159825B24C22002F373E647C2DA62A854F3841C00FD5985D03227CA9B54A69380BA9D63BE738BDF9E65C247E43E1220EEDD9281DCA78B32A4E1B786B7697ED0C3195D5AF2990881B11D6FC9EC9F940067B2DEA2A516FAA5F269C98F0B67628A6D2708515A4A58041AA17A93E4C4DD95C85BC38351DDA1DCF3DFD91C505B22383132649CF9F9233852C7207075BCF43C71038F043F1EC53E9787FB051B7927D020903233C16897B993C8089D8464451F086E756CF20E46CE6ED4A6AC5C327A0AAFBECBAAFD177969E7C952C76A4F4E7C85BF7F63"; + q: String := "F6ACF0790A250802C8D45DAC549CDBEF7806D5877A5DF0069136A458FAC4F0B0858060A873DA6355A965A064A0BC1BBB874872CD7ED89674AD407533041E74BCA317EC73597D335115523F61A05071E5ED81EE2A05331F65D4DC7A25AD7938B124CF03F49154B6693FB0B598B33ABDEF85C599A57A9B7347EAFF82638E1CBC28FCDFFF1FF04A18C2DBF3938395C2F8D1782B43D3A25EF7633B5DDAC89EFD3BAA64D976425A0891E00B876E9DE9FE4B6492B0EA8DFC7C8DEEC61721356EC816295B1BD9CD9DA3E30D2D90DC9CB3987F4BE042104900E036F3044A016749EF910CCFB9F377A90849B4CCCF4471A74E67EF6C814C9467"; + u: String := "854B89ED10F52258D00D6B3FA7F1FD22752804668F51FF7806DB82E22CB8B3AA8448D9B8E9DB14D31A36AEC2BCFA89E341B7334D494E97ED8051244136192233332C4612D963E7B6AF2535FDB7FE97E28DDFEBDFB3E1AFC29D05DBDF37106A817D3AB1864C7F7F247982897EDA6A92BED47D9C68305CD170C7301ACEB05F8A6382E73CC7614B2D8D758669B3A99AB64114809254B0BE21F40341A5B48B9B032603B14875B87EB5E16603FD16552E146A0FC6964958DFC25AA9FFCCD1ED1F4DEAF9FBAA0D7357F5FF0803FEB9BA78E74AC6B3070F417CEC6CFC7A3CF1E305FC7B76B7ED71893999AF797B2EBDE41FE90F076CCEDBFB"; + begin + -- initialize RSA key with values previously obtained from EuCrypt + Hex2Octets( n, SKey.n ); + Hex2Octets( e, SKey.e ); + Hex2Octets( d, SKey.d ); + Hex2Octets( p, SKey.p ); + Hex2Octets( q, SKey.q ); + Hex2Octets( u, SKey.u ); + -- copy n and e for public key + PKey.n := SKey.n; + PKey.e := SKey.e; + -- get random data for "message" + RNG.Get_Octets(Msg); + + -- pack the message into corresponding packet + Pkt := Packing.Pack( Msg, PKey ); + -- unpack and check the result + Decr_Msg := Packing.Unpack( Pkt, SKey, Success ); + if (not Success) or (Decr_Msg /= Msg) then + Put_Line("FAIL: pack/unpack with RSA."); + else + Put_Line("PASS: pack/unpack with RSA."); + end if; + + -- try to unpack a mangled package + Pkt(Pkt'First + 3) := Pkt(Pkt'First + 3) and 16#AB#; + Decr_Msg := (others => 0); + Decr_Msg := Packing.Unpack( Pkt, SKey, Success ); + if Success then + Put_Line("FAIL: pack/unpack with RSA on mangled package."); + else + Put_Line("PASS: pack/unpack with RSA on mangled package."); + end if; + + end Test_Pack_Unpack_RSA; + +-- helper methods + procedure Hex2Octets( Hex: in String; O: out Raw_Types.Octets ) is + S : String := "16#AA#"; + -- to make sure that input String has EVEN number of chars (ie full octets) + H : String(1..Hex'Length+Hex'Length mod 2) := (others=>'0'); + begin + -- first char is 0 if needed to cover full octet... + H(H'Length-Hex'Length+1..H'Length) := Hex; + O := (others => 0); + for I in 0 .. H'Length/2-1 loop + S := "16#" & H(H'First + I*2 .. H'First + I*2 + 1) & "#"; + O(O'Last - H'Length/2 + 1 + I) := Unsigned_8'Value(S); + end loop; + end Hex2Octets; + end Test_Packing; diff -uNr a/smg_comms/tests/test_packing.ads b/smg_comms/tests/test_packing.ads --- a/smg_comms/tests/test_packing.ads 2ffca1d2b5811d3ec15095f73bc55207e4de623978585c4d4e408cf881a7ca6a5e6d4bb9ef3ccd6888f74377cdefd085c96314559a916200999bee45ed61a6ae +++ b/smg_comms/tests/test_packing.ads 0b774f9947b49ec87836a030ba9ae0b8ad0c802df3faa23a00d1019ba4cef610765f36cd7e36212ebdb80ee32691e39277a42c11f88e9b3fa949e1cab6fa676f @@ -9,5 +9,13 @@ -- utility method for printing an array of octets procedure Print(Data: in Raw_Types.Octets; Msg: in String); - procedure Test_Pack_Unpack; + -- testing pack/unpack for Serpent + procedure Test_Pack_Unpack_Serpent; + + -- testing pack/unpack for RSA + procedure Test_Pack_Unpack_RSA; + +-- helper methods + procedure Hex2Octets( Hex: in String; O: out Raw_Types.Octets ); + end Test_Packing; diff -uNr a/smg_comms/tests/test_rsa_oaep.adb b/smg_comms/tests/test_rsa_oaep.adb --- a/smg_comms/tests/test_rsa_oaep.adb faed716c9ff42cedc9353eed11cab82ee3be11da5c4ae417cda49ab092d68cd74a773052881ea831296aef905c7b22ee56a25886424219388e4457dcb99cf4fb +++ b/smg_comms/tests/test_rsa_oaep.adb a980e689b22403c41481df1d9c86740a75f1ae0b386bd2425ab75d4e4dc4397165a0e14f58bfd0b6fe20e02f75528014e3ea1a730f75507bb8343329dd7e2b6f @@ -14,7 +14,7 @@ procedure test_char_array is S : String := OAEP.TMSR_STR; - O : Octets := OAEP.TMSR; + O : Octets := Raw_Types.OAEP_RESERVED; A : char_array(0..O'Length-1) := (others => '0'); B : Octets(0..O'Length -1) := (others => 0); Fail : Boolean := FALSE; diff -uNr a/smg_comms/tests/testall.adb b/smg_comms/tests/testall.adb --- a/smg_comms/tests/testall.adb b150853b3e031aa9d0656a19645c7701c6f2fe543f2be6febde1d8b07d80eb4c4b690cb68d26a77d04d4ec0b85b7ab700bd20d4c2714f0f154fc3b848016b0ca +++ b/smg_comms/tests/testall.adb 01ded6598577bf4fb8027beaa9678239ef98f27abb62e3c5739b9347e4a747a1107052a6f908c7b4d3603c8db762b59aaac9efa6ebf64c8cffe1287985d87bb6 @@ -7,9 +7,10 @@ procedure testall is begin Test_Serpent.Selftest; - Test_Packing.Test_Pack_Unpack; Test_RSA_OAEP.test_char_array; Test_RSA_OAEP.test_oaep; Test_RSA_OAEP.test_rsa; Test_RSA_OAEP.test_rsa_oaep; + Test_Packing.Test_Pack_Unpack_Serpent; + Test_Packing.Test_Pack_Unpack_RSA; end testall;