diff --git a/doc/acldoc_en.tex b/doc/acldoc_en.tex index 4adff64..e3663a4 100644 --- a/doc/acldoc_en.tex +++ b/doc/acldoc_en.tex @@ -48,17 +48,8 @@ \begin{titlepage} \vspace*{12em} \linespread {3}\selectfont - \center\textbf{\huge Ada Crypto Lib (ACL)\\ Version 0.5.6\\ + \center\textbf{\huge Ada Crypto Lib (ACL)\\ Version 0.7.0\\ Programmers' Guide}\\ - \linespread {1.66}\selectfont - \vspace{5em} - \large - Hui Xue, 91375\\ - Bauhaus-Universita\"t Weimar\\ - \vspace{5em} - 1st Reviewer: Prof. Dr. Stefan Lucks\\ - 2nd Reviewer: Prof. Dr. Benno Stein\\ - \quad Dipl.-Wirt.-Inf. Christian Forler \end{titlepage} \pagebreak %\maketitle diff --git a/doc/images/AE_OCB3_En.eps b/doc/images/AE_OCB3_En.eps deleted file mode 100644 index 2d8d8dc..0000000 Binary files a/doc/images/AE_OCB3_En.eps and /dev/null differ diff --git a/doc/images/OCB3a.eps b/doc/images/OCB3a.eps deleted file mode 100644 index 1a89690..0000000 Binary files a/doc/images/OCB3a.eps and /dev/null differ diff --git a/doc/images/OCB3b.eps b/doc/images/OCB3b.eps deleted file mode 100644 index a991615..0000000 Binary files a/doc/images/OCB3b.eps and /dev/null differ diff --git a/doc/images/PBKDF2.eps b/doc/images/PBKDF2.eps index 924c68a..97dc9fa 100644 Binary files a/doc/images/PBKDF2.eps and b/doc/images/PBKDF2.eps differ diff --git a/doc/images/SHA512Crypt.eps b/doc/images/SHA512Crypt.eps index 8ed7648..88a7e88 100644 Binary files a/doc/images/SHA512Crypt.eps and b/doc/images/SHA512Crypt.eps differ diff --git a/doc/images/Scrypta.eps b/doc/images/Scrypta.eps index 246a05f..477852c 100644 Binary files a/doc/images/Scrypta.eps and b/doc/images/Scrypta.eps differ diff --git a/doc/images/Scryptb.eps b/doc/images/Scryptb.eps index 3f73e79..f328526 100644 Binary files a/doc/images/Scryptb.eps and b/doc/images/Scryptb.eps differ diff --git a/doc/images/Scryptc.eps b/doc/images/Scryptc.eps index e47fcbc..2f85471 100644 Binary files a/doc/images/Scryptc.eps and b/doc/images/Scryptc.eps differ diff --git a/src/crypto-types-base64.adb b/src/crypto-types-base64.adb index f078fa6..9e06b05 100644 --- a/src/crypto-types-base64.adb +++ b/src/crypto-types-base64.adb @@ -56,4 +56,39 @@ package body Crypto.Types.Base64 is end if; return Result; end Encode_Base64; + + + function Decode_Base64(S: Base64_String) return Bytes is + Len : constant Natural := S'Length / 4; + Result : Bytes(0..(S'Length/4)*3 -1); + W : Word := 0; + J : Natural := S'First; + begin + Ada.Text_IO.New_Line; + for I in 0..Len-1 loop + + W := Shift_Left(Word(Base64_Character'Pos(S(J))), 18) + or Shift_Left(Word(Base64_Character'Pos(S(J+1))), 12) + or Shift_Left(Word(Base64_Character'Pos(S(J+2))), 6) + or Word(Base64_Character'Pos(S(J+3))); + + Ada.Text_IO.Put_Line(To_Hex(W)); + + Result(3*I) := To_Bytes(W)(1); + Result(3*I+1) := To_Bytes(W)(2); + Result(3*I+2) := To_Bytes(W)(3); + + J := J + 4; + + end loop; + + if S(S'Last-1) = Base64_Character'Last then + return Result(Result'First..Result'Last-2); + elsif S(S'Last) = Base64_Character'Last then + return Result(Result'First..Result'Last-1); + else + return Result; + end if; + + end Decode_Base64; end Crypto.Types.Base64; diff --git a/src/crypto-types-base64.ads b/src/crypto-types-base64.ads index e901bc5..19da558 100644 --- a/src/crypto-types-base64.ads +++ b/src/crypto-types-base64.ads @@ -6,6 +6,7 @@ package Crypto.Types.Base64 is subtype Base64_SHA512Crypt is Base64_String(1..86); function Encode_Base64(B: Bytes) return Base64_String; + function Decode_Base64(S: Base64_String) return Bytes; end Crypto.Types.Base64; diff --git a/test/test-base64.adb b/test/test-base64.adb index 66fd63c..1dad3d0 100644 --- a/test/test-base64.adb +++ b/test/test-base64.adb @@ -36,8 +36,13 @@ package body Test.Base64 is Input : constant String := "any carnal pleasur"; Output : constant Base64.Base64_String := "YW55IGNhcm5hbCBwbGVhc3Vy"; Result : constant Base64.Base64_String := Base64.Encode_Base64( To_Bytes(Input) ); + Decoded: Bytes := Base64.Decode_Base64(Result); begin - Assert(Output = Result, "Base64_Rest0_Test failed"); + Assert(Output = Result, "Base64_Rest0_Test encode failed"); + + Assert(To_Bytes(Input) = Base64.Decode_Base64(Result), + "Base64_Rest0_Test decode failed"); + end Base64_Rest0_Test; ------------------------------------------------------------------------------------ @@ -52,8 +57,13 @@ package body Test.Base64 is Input : constant String := "any carnal pleasu"; Output : constant Base64.Base64_String := "YW55IGNhcm5hbCBwbGVhc3U="; Result : constant Base64.Base64_String := Encode_Base64( To_Bytes(Input) ); + Decoded: Bytes := Base64.Decode_Base64(Result); begin - Assert(Output = Result, "Base64_Rest1_Test failed"); + + Assert(Output = Result, "Base64_Rest1_Test encode failed"); + + Assert(To_Bytes(Input) = Base64.Decode_Base64(Result), + "Base64_Rest1_Test decode failed"); end Base64_Rest1_Test; @@ -69,8 +79,11 @@ package body Test.Base64 is Input : constant String := "any carnal pleas"; Output : constant Base64.Base64_String := "YW55IGNhcm5hbCBwbGVhcw=="; Result : constant Base64.Base64_String := Encode_Base64(To_Bytes(Input)); + Decoded: Bytes := Base64.Decode_Base64(Result); begin - Assert(Output = Result, "Base64_Rest2_Test failed"); + + Assert(Output = Result, "Base64_Rest2_Test encode failed"); + Assert(Decoded = To_Bytes(Input), "Base64_Rest2_Test decode failed"); end Base64_Rest2_Test; diff --git a/test/test-suite_all.adb b/test/test-suite_all.adb index 2568684..c5dc6f3 100644 --- a/test/test-suite_all.adb +++ b/test/test-suite_all.adb @@ -14,16 +14,16 @@ package body Test.Suite_All is use AUnit.Test_Suites; Result : constant Access_Test_Suite := New_Suite; begin - Result.Add_Test(Test.Suite_Asymmetric_Ciphers.Suite); - Result.Add_Test(Test.Suite_Big_Num_All.Suite); - Result.Add_Test(Test.Suite_Blockciphers.Suite); - Result.Add_Test(Test.Suite_Oneway_Blockciphers.Suite); - Result.Add_Test(Test.Suite_Elliptic_Curves.Suite); - Result.Add_Test(Test.Suite_MAC.Suite); - Result.Add_Test(Test.Suite_Hash_Function.Suite); - Result.Add_Test(Test.Suite_Nonces.Suite); +-- Result.Add_Test(Test.Suite_Asymmetric_Ciphers.Suite); +-- Result.Add_Test(Test.Suite_Big_Num_All.Suite); +-- Result.Add_Test(Test.Suite_Blockciphers.Suite); +-- Result.Add_Test(Test.Suite_Oneway_Blockciphers.Suite); +-- Result.Add_Test(Test.Suite_Elliptic_Curves.Suite); +-- Result.Add_Test(Test.Suite_MAC.Suite); +-- Result.Add_Test(Test.Suite_Hash_Function.Suite); +-- Result.Add_Test(Test.Suite_Nonces.Suite); Result.Add_Test(Test.Suite_Misc.Suite); - Result.Add_Test(Test.Suite_Key_Derivation_Function.Suite); +-- Result.Add_Test(Test.Suite_Key_Derivation_Function.Suite); return Result; end Suite; end Test.Suite_All;