From 00fc794202b7a516b3b87b4831c0d3d430c96ff5 Mon Sep 17 00:00:00 2001 From: ImKcat Date: Thu, 5 Sep 2019 17:24:56 +0800 Subject: [PATCH] fix: Fixing pods build issue --- .swift-version | 1 - CatCrypto.podspec | 6 +- CatCrypto.xcodeproj/project.pbxproj | 224 +++++++----- .../xcschemes/CommonCryptoModuleMap.xcscheme | 80 +++++ Sources/ModuleMaps/Argon2/bench.c | 111 ------ Sources/ModuleMaps/Argon2/blake2.h | 2 +- Sources/ModuleMaps/Argon2/genkat.c | 207 ----------- Sources/ModuleMaps/Argon2/genkat.h | 51 --- Sources/ModuleMaps/Argon2/opt.c | 283 --------------- Sources/ModuleMaps/Argon2/run.c | 337 ------------------ Sources/ModuleMaps/Argon2/test.c | 289 --------------- 11 files changed, 225 insertions(+), 1366 deletions(-) delete mode 100644 .swift-version create mode 100644 CatCrypto.xcodeproj/xcshareddata/xcschemes/CommonCryptoModuleMap.xcscheme delete mode 100755 Sources/ModuleMaps/Argon2/bench.c delete mode 100755 Sources/ModuleMaps/Argon2/genkat.c delete mode 100755 Sources/ModuleMaps/Argon2/genkat.h delete mode 100755 Sources/ModuleMaps/Argon2/opt.c delete mode 100755 Sources/ModuleMaps/Argon2/run.c delete mode 100755 Sources/ModuleMaps/Argon2/test.c diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 5186d07..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.0 diff --git a/CatCrypto.podspec b/CatCrypto.podspec index 29406d3..5179e7c 100644 --- a/CatCrypto.podspec +++ b/CatCrypto.podspec @@ -10,15 +10,17 @@ Pod::Spec.new do |s| s.name = 'CatCrypto' s.version = '0.3.2' s.summary = 'An easy way for hashing and encryption.' - s.description = <<-DESC + s.description = <<-DESC CatCrypto include a series of hashing and encryption functions. DESC s.homepage = 'https://github.com/ImKcat/CatCrypto' s.license = { :type => 'MIT', :file => 'LICENSE' } - s.author = { 'Kcat' => 'kcatdeveloper@icloud.com' } + s.author = { 'Kcat' => 'imkcat@icloud.com' } s.source = { :git => 'https://github.com/ImKcat/CatCrypto.git', :tag => s.version.to_s } s.social_media_url = 'https://imkcat.com' + s.swift_versions = '4.0' + s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.10' s.tvos.deployment_target = '9.0' diff --git a/CatCrypto.xcodeproj/project.pbxproj b/CatCrypto.xcodeproj/project.pbxproj index d3a06e4..4de16bd 100644 --- a/CatCrypto.xcodeproj/project.pbxproj +++ b/CatCrypto.xcodeproj/project.pbxproj @@ -37,19 +37,6 @@ C328B7971FF4DC4900943D75 /* CatCrypto.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C330B4961FDE93AB005AEECC /* CatCrypto.framework */; }; C328B79E1FF4DCC400943D75 /* MessageDigestCryptoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C328B79D1FF4DCC400943D75 /* MessageDigestCryptoTests.swift */; }; C330B4A81FDE93AC005AEECC /* CatCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = C330B4981FDE93AC005AEECC /* CatCrypto.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C330B4C41FDE94E9005AEECC /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C356174B1FDD7C9A005316BF /* argon2.c */; }; - C330B4CB1FDE94E9005AEECC /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C356175C1FDD7C9B005316BF /* core.c */; }; - C330B4CD1FDE94E9005AEECC /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C35617501FDD7C9B005316BF /* encoding.c */; }; - C330B4CF1FDE94E9005AEECC /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176E1FDD7E5A005316BF /* ref.c */; }; - C330B4D11FDE94E9005AEECC /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176B1FDD7E44005316BF /* thread.c */; }; - C33EB18F2320CF9C00988497 /* blamka-round-ref.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EB18A2320CF9C00988497 /* blamka-round-ref.h */; }; - C33EB1902320CF9C00988497 /* blamka-round-opt.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EB18B2320CF9C00988497 /* blamka-round-opt.h */; }; - C33EB1912320CF9C00988497 /* blake2.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EB18C2320CF9C00988497 /* blake2.h */; }; - C33EB1922320CF9C00988497 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C33EB18D2320CF9C00988497 /* blake2b.c */; }; - C33EB1932320CF9C00988497 /* blake2-impl.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EB18E2320CF9C00988497 /* blake2-impl.h */; }; - C33EB1952320D4C000988497 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C33EB18D2320CF9C00988497 /* blake2b.c */; }; - C33EB1962320D54700988497 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C33EB18D2320CF9C00988497 /* blake2b.c */; }; - C33EB1972320D54F00988497 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C33EB18D2320CF9C00988497 /* blake2b.c */; }; C358E78F1FE2318C00A352D0 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = C358E78E1FE2318C00A352D0 /* LICENSE */; }; C367290C1FF4920E005BE1A8 /* SHA.swift in Sources */ = {isa = PBXBuildFile; fileRef = C367290B1FF4920E005BE1A8 /* SHA.swift */; }; C367290D1FF4920E005BE1A8 /* SHA.swift in Sources */ = {isa = PBXBuildFile; fileRef = C367290B1FF4920E005BE1A8 /* SHA.swift */; }; @@ -67,6 +54,62 @@ C38A78FA2003C2260028D981 /* Decryption.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38A78F82003C2260028D981 /* Decryption.swift */; }; C38A78FB2003C2260028D981 /* Decryption.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38A78F82003C2260028D981 /* Decryption.swift */; }; C38A78FC2003C2260028D981 /* Decryption.swift in Sources */ = {isa = PBXBuildFile; fileRef = C38A78F82003C2260028D981 /* Decryption.swift */; }; + C392E2762320FED300DDB1D9 /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E25F2320FED200DDB1D9 /* encoding.c */; }; + C392E2772320FED300DDB1D9 /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E25F2320FED200DDB1D9 /* encoding.c */; }; + C392E2782320FED300DDB1D9 /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E25F2320FED200DDB1D9 /* encoding.c */; }; + C392E2792320FED300DDB1D9 /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E25F2320FED200DDB1D9 /* encoding.c */; }; + C392E27A2320FED300DDB1D9 /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2602320FED200DDB1D9 /* ref.c */; }; + C392E27B2320FED300DDB1D9 /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2602320FED200DDB1D9 /* ref.c */; }; + C392E27C2320FED300DDB1D9 /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2602320FED200DDB1D9 /* ref.c */; }; + C392E27D2320FED300DDB1D9 /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2602320FED200DDB1D9 /* ref.c */; }; + C392E2822320FED300DDB1D9 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2622320FED200DDB1D9 /* thread.h */; }; + C392E2832320FED300DDB1D9 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2622320FED200DDB1D9 /* thread.h */; }; + C392E2842320FED300DDB1D9 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2622320FED200DDB1D9 /* thread.h */; }; + C392E2852320FED300DDB1D9 /* thread.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2622320FED200DDB1D9 /* thread.h */; }; + C392E28A2320FED300DDB1D9 /* blamka-round-ref.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2652320FED200DDB1D9 /* blamka-round-ref.h */; }; + C392E28B2320FED300DDB1D9 /* blamka-round-ref.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2652320FED200DDB1D9 /* blamka-round-ref.h */; }; + C392E28C2320FED300DDB1D9 /* blamka-round-ref.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2652320FED200DDB1D9 /* blamka-round-ref.h */; }; + C392E28D2320FED300DDB1D9 /* blamka-round-ref.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2652320FED200DDB1D9 /* blamka-round-ref.h */; }; + C392E28E2320FED300DDB1D9 /* blamka-round-opt.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2662320FED200DDB1D9 /* blamka-round-opt.h */; }; + C392E28F2320FED300DDB1D9 /* blamka-round-opt.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2662320FED200DDB1D9 /* blamka-round-opt.h */; }; + C392E2902320FED300DDB1D9 /* blamka-round-opt.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2662320FED200DDB1D9 /* blamka-round-opt.h */; }; + C392E2912320FED300DDB1D9 /* blamka-round-opt.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2662320FED200DDB1D9 /* blamka-round-opt.h */; }; + C392E2922320FED300DDB1D9 /* blake2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2672320FED200DDB1D9 /* blake2.h */; }; + C392E2932320FED300DDB1D9 /* blake2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2672320FED200DDB1D9 /* blake2.h */; }; + C392E2942320FED300DDB1D9 /* blake2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2672320FED200DDB1D9 /* blake2.h */; }; + C392E2952320FED300DDB1D9 /* blake2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2672320FED200DDB1D9 /* blake2.h */; }; + C392E2962320FED300DDB1D9 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2682320FED200DDB1D9 /* blake2b.c */; }; + C392E2972320FED300DDB1D9 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2682320FED200DDB1D9 /* blake2b.c */; }; + C392E2982320FED300DDB1D9 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2682320FED200DDB1D9 /* blake2b.c */; }; + C392E2992320FED300DDB1D9 /* blake2b.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2682320FED200DDB1D9 /* blake2b.c */; }; + C392E29A2320FED300DDB1D9 /* blake2-impl.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2692320FED200DDB1D9 /* blake2-impl.h */; }; + C392E29B2320FED300DDB1D9 /* blake2-impl.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2692320FED200DDB1D9 /* blake2-impl.h */; }; + C392E29C2320FED300DDB1D9 /* blake2-impl.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2692320FED200DDB1D9 /* blake2-impl.h */; }; + C392E29D2320FED300DDB1D9 /* blake2-impl.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2692320FED200DDB1D9 /* blake2-impl.h */; }; + C392E29E2320FED300DDB1D9 /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26A2320FED200DDB1D9 /* core.c */; }; + C392E29F2320FED300DDB1D9 /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26A2320FED200DDB1D9 /* core.c */; }; + C392E2A02320FED300DDB1D9 /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26A2320FED200DDB1D9 /* core.c */; }; + C392E2A12320FED300DDB1D9 /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26A2320FED200DDB1D9 /* core.c */; }; + C392E2A62320FED300DDB1D9 /* encoding.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26C2320FED200DDB1D9 /* encoding.h */; }; + C392E2A72320FED300DDB1D9 /* encoding.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26C2320FED200DDB1D9 /* encoding.h */; }; + C392E2A82320FED300DDB1D9 /* encoding.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26C2320FED200DDB1D9 /* encoding.h */; }; + C392E2A92320FED300DDB1D9 /* encoding.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26C2320FED200DDB1D9 /* encoding.h */; }; + C392E2AA2320FED300DDB1D9 /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26D2320FED200DDB1D9 /* argon2.c */; }; + C392E2AB2320FED300DDB1D9 /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26D2320FED200DDB1D9 /* argon2.c */; }; + C392E2AC2320FED300DDB1D9 /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26D2320FED200DDB1D9 /* argon2.c */; }; + C392E2AD2320FED300DDB1D9 /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E26D2320FED200DDB1D9 /* argon2.c */; }; + C392E2B22320FED300DDB1D9 /* core.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26F2320FED200DDB1D9 /* core.h */; }; + C392E2B32320FED300DDB1D9 /* core.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26F2320FED200DDB1D9 /* core.h */; }; + C392E2B42320FED300DDB1D9 /* core.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26F2320FED200DDB1D9 /* core.h */; }; + C392E2B52320FED300DDB1D9 /* core.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E26F2320FED200DDB1D9 /* core.h */; }; + C392E2BA2320FED300DDB1D9 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2712320FED200DDB1D9 /* thread.c */; }; + C392E2BB2320FED300DDB1D9 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2712320FED200DDB1D9 /* thread.c */; }; + C392E2BC2320FED300DDB1D9 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2712320FED200DDB1D9 /* thread.c */; }; + C392E2BD2320FED300DDB1D9 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C392E2712320FED200DDB1D9 /* thread.c */; }; + C392E2BF2320FEF500DDB1D9 /* argon2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2BE2320FEF500DDB1D9 /* argon2.h */; }; + C392E2C02320FEF500DDB1D9 /* argon2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2BE2320FEF500DDB1D9 /* argon2.h */; }; + C392E2C12320FEF500DDB1D9 /* argon2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2BE2320FEF500DDB1D9 /* argon2.h */; }; + C392E2C22320FEF500DDB1D9 /* argon2.h in Headers */ = {isa = PBXBuildFile; fileRef = C392E2BE2320FEF500DDB1D9 /* argon2.h */; }; C393A5BA1FF0F85600B69167 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C393A5B91FF0F85600B69167 /* StringExtension.swift */; }; C393A5BB1FF0F85600B69167 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C393A5B91FF0F85600B69167 /* StringExtension.swift */; }; C393A5BC1FF0F85600B69167 /* StringExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C393A5B91FF0F85600B69167 /* StringExtension.swift */; }; @@ -112,21 +155,6 @@ C3D6DD2D1FF39FFE0005C3D1 /* Contextual.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3D6DD291FF39FFE0005C3D1 /* Contextual.swift */; }; C3DF7A311FF73BB4007BDC59 /* ArgonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3DF7A301FF73BB4007BDC59 /* ArgonTests.swift */; }; C3E273851FE4267D0026655E /* CatCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = C330B4981FDE93AC005AEECC /* CatCrypto.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C3E273861FE42B000026655E /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C356174B1FDD7C9A005316BF /* argon2.c */; }; - C3E273881FE42B000026655E /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C356175C1FDD7C9B005316BF /* core.c */; }; - C3E273891FE42B000026655E /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C35617501FDD7C9B005316BF /* encoding.c */; }; - C3E2738A1FE42B000026655E /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176E1FDD7E5A005316BF /* ref.c */; }; - C3E2738B1FE42B000026655E /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176B1FDD7E44005316BF /* thread.c */; }; - C3E2738C1FE42B010026655E /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C356174B1FDD7C9A005316BF /* argon2.c */; }; - C3E2738E1FE42B010026655E /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C356175C1FDD7C9B005316BF /* core.c */; }; - C3E2738F1FE42B010026655E /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C35617501FDD7C9B005316BF /* encoding.c */; }; - C3E273901FE42B010026655E /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176E1FDD7E5A005316BF /* ref.c */; }; - C3E273911FE42B010026655E /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176B1FDD7E44005316BF /* thread.c */; }; - C3E273921FE42B020026655E /* argon2.c in Sources */ = {isa = PBXBuildFile; fileRef = C356174B1FDD7C9A005316BF /* argon2.c */; }; - C3E273941FE42B020026655E /* core.c in Sources */ = {isa = PBXBuildFile; fileRef = C356175C1FDD7C9B005316BF /* core.c */; }; - C3E273951FE42B020026655E /* encoding.c in Sources */ = {isa = PBXBuildFile; fileRef = C35617501FDD7C9B005316BF /* encoding.c */; }; - C3E273961FE42B020026655E /* ref.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176E1FDD7E5A005316BF /* ref.c */; }; - C3E273971FE42B020026655E /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = C356176B1FDD7E44005316BF /* thread.c */; }; C3FD6D36200368BC001394CF /* EnumDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FD6D35200368BC001394CF /* EnumDescription.swift */; }; C3FD6D37200368BC001394CF /* EnumDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FD6D35200368BC001394CF /* EnumDescription.swift */; }; C3FD6D38200368BC001394CF /* EnumDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3FD6D35200368BC001394CF /* EnumDescription.swift */; }; @@ -184,26 +212,26 @@ C330B4961FDE93AB005AEECC /* CatCrypto.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CatCrypto.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C330B4981FDE93AC005AEECC /* CatCrypto.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CatCrypto.h; sourceTree = ""; }; C330B4991FDE93AC005AEECC /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - C33EB18A2320CF9C00988497 /* blamka-round-ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "blamka-round-ref.h"; sourceTree = ""; }; - C33EB18B2320CF9C00988497 /* blamka-round-opt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "blamka-round-opt.h"; sourceTree = ""; }; - C33EB18C2320CF9C00988497 /* blake2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blake2.h; sourceTree = ""; }; - C33EB18D2320CF9C00988497 /* blake2b.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blake2b.c; sourceTree = ""; }; - C33EB18E2320CF9C00988497 /* blake2-impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "blake2-impl.h"; sourceTree = ""; }; - C35617411FDD765D005316BF /* argon2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = argon2.h; sourceTree = ""; }; C35617421FDD765D005316BF /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = ""; }; - C356174B1FDD7C9A005316BF /* argon2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = argon2.c; sourceTree = ""; }; - C356174D1FDD7C9A005316BF /* core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = core.h; sourceTree = ""; }; - C35617501FDD7C9B005316BF /* encoding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = encoding.c; sourceTree = ""; }; - C356175C1FDD7C9B005316BF /* core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = core.c; sourceTree = ""; }; - C356175D1FDD7C9B005316BF /* encoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = encoding.h; sourceTree = ""; }; - C356176B1FDD7E44005316BF /* thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = thread.c; sourceTree = ""; }; - C356176C1FDD7E44005316BF /* thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = thread.h; sourceTree = ""; }; - C356176E1FDD7E5A005316BF /* ref.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ref.c; sourceTree = ""; }; C358E78E1FE2318C00A352D0 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; C367290B1FF4920E005BE1A8 /* SHA.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SHA.swift; sourceTree = ""; }; C36729101FF496D4005BE1A8 /* Crypto.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Crypto.swift; sourceTree = ""; }; C38A78F32003C01C0028D981 /* Encryption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Encryption.swift; sourceTree = ""; }; C38A78F82003C2260028D981 /* Decryption.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Decryption.swift; sourceTree = ""; }; + C392E25F2320FED200DDB1D9 /* encoding.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = encoding.c; sourceTree = ""; }; + C392E2602320FED200DDB1D9 /* ref.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ref.c; sourceTree = ""; }; + C392E2622320FED200DDB1D9 /* thread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = thread.h; sourceTree = ""; }; + C392E2652320FED200DDB1D9 /* blamka-round-ref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "blamka-round-ref.h"; sourceTree = ""; }; + C392E2662320FED200DDB1D9 /* blamka-round-opt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "blamka-round-opt.h"; sourceTree = ""; }; + C392E2672320FED200DDB1D9 /* blake2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = blake2.h; sourceTree = ""; }; + C392E2682320FED200DDB1D9 /* blake2b.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = blake2b.c; sourceTree = ""; }; + C392E2692320FED200DDB1D9 /* blake2-impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "blake2-impl.h"; sourceTree = ""; }; + C392E26A2320FED200DDB1D9 /* core.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = core.c; sourceTree = ""; }; + C392E26C2320FED200DDB1D9 /* encoding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = encoding.h; sourceTree = ""; }; + C392E26D2320FED200DDB1D9 /* argon2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = argon2.c; sourceTree = ""; }; + C392E26F2320FED200DDB1D9 /* core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = core.h; sourceTree = ""; }; + C392E2712320FED200DDB1D9 /* thread.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = thread.c; sourceTree = ""; }; + C392E2BE2320FEF500DDB1D9 /* argon2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = argon2.h; sourceTree = ""; }; C393A5B91FF0F85600B69167 /* StringExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringExtension.swift; sourceTree = ""; }; C3945E851FE3CBAE009A203D /* CatCrypto.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CatCrypto.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C3945EAD1FE3CE48009A203D /* CatCrypto.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = CatCrypto.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -332,20 +360,20 @@ C356173F1FDD765D005316BF /* Argon2 */ = { isa = PBXGroup; children = ( - C33EB18A2320CF9C00988497 /* blamka-round-ref.h */, - C33EB18B2320CF9C00988497 /* blamka-round-opt.h */, - C33EB18C2320CF9C00988497 /* blake2.h */, - C33EB18D2320CF9C00988497 /* blake2b.c */, - C33EB18E2320CF9C00988497 /* blake2-impl.h */, - C356174B1FDD7C9A005316BF /* argon2.c */, - C35617411FDD765D005316BF /* argon2.h */, - C356175C1FDD7C9B005316BF /* core.c */, - C356174D1FDD7C9A005316BF /* core.h */, - C35617501FDD7C9B005316BF /* encoding.c */, - C356175D1FDD7C9B005316BF /* encoding.h */, - C356176E1FDD7E5A005316BF /* ref.c */, - C356176B1FDD7E44005316BF /* thread.c */, - C356176C1FDD7E44005316BF /* thread.h */, + C392E2652320FED200DDB1D9 /* blamka-round-ref.h */, + C392E2662320FED200DDB1D9 /* blamka-round-opt.h */, + C392E2672320FED200DDB1D9 /* blake2.h */, + C392E2682320FED200DDB1D9 /* blake2b.c */, + C392E2692320FED200DDB1D9 /* blake2-impl.h */, + C392E26D2320FED200DDB1D9 /* argon2.c */, + C392E2BE2320FEF500DDB1D9 /* argon2.h */, + C392E26A2320FED200DDB1D9 /* core.c */, + C392E26F2320FED200DDB1D9 /* core.h */, + C392E25F2320FED200DDB1D9 /* encoding.c */, + C392E26C2320FED200DDB1D9 /* encoding.h */, + C392E2602320FED200DDB1D9 /* ref.c */, + C392E2712320FED200DDB1D9 /* thread.c */, + C392E2622320FED200DDB1D9 /* thread.h */, C35617421FDD765D005316BF /* module.modulemap */, C358E78E1FE2318C00A352D0 /* LICENSE */, ); @@ -423,11 +451,15 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + C392E2822320FED300DDB1D9 /* thread.h in Headers */, C330B4A81FDE93AC005AEECC /* CatCrypto.h in Headers */, - C33EB18F2320CF9C00988497 /* blamka-round-ref.h in Headers */, - C33EB1902320CF9C00988497 /* blamka-round-opt.h in Headers */, - C33EB1912320CF9C00988497 /* blake2.h in Headers */, - C33EB1932320CF9C00988497 /* blake2-impl.h in Headers */, + C392E29A2320FED300DDB1D9 /* blake2-impl.h in Headers */, + C392E2922320FED300DDB1D9 /* blake2.h in Headers */, + C392E2BF2320FEF500DDB1D9 /* argon2.h in Headers */, + C392E28E2320FED300DDB1D9 /* blamka-round-opt.h in Headers */, + C392E2B22320FED300DDB1D9 /* core.h in Headers */, + C392E28A2320FED300DDB1D9 /* blamka-round-ref.h in Headers */, + C392E2A62320FED300DDB1D9 /* encoding.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -435,7 +467,15 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + C392E2842320FED300DDB1D9 /* thread.h in Headers */, C3945F1E1FE3D57D009A203D /* CatCrypto.h in Headers */, + C392E29C2320FED300DDB1D9 /* blake2-impl.h in Headers */, + C392E2942320FED300DDB1D9 /* blake2.h in Headers */, + C392E2C12320FEF500DDB1D9 /* argon2.h in Headers */, + C392E2902320FED300DDB1D9 /* blamka-round-opt.h in Headers */, + C392E2B42320FED300DDB1D9 /* core.h in Headers */, + C392E28C2320FED300DDB1D9 /* blamka-round-ref.h in Headers */, + C392E2A82320FED300DDB1D9 /* encoding.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -443,7 +483,15 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + C392E2852320FED300DDB1D9 /* thread.h in Headers */, C3945F241FE3D57D009A203D /* CatCrypto.h in Headers */, + C392E29D2320FED300DDB1D9 /* blake2-impl.h in Headers */, + C392E2952320FED300DDB1D9 /* blake2.h in Headers */, + C392E2C22320FEF500DDB1D9 /* argon2.h in Headers */, + C392E2912320FED300DDB1D9 /* blamka-round-opt.h in Headers */, + C392E2B52320FED300DDB1D9 /* core.h in Headers */, + C392E28D2320FED300DDB1D9 /* blamka-round-ref.h in Headers */, + C392E2A92320FED300DDB1D9 /* encoding.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -451,7 +499,15 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + C392E2832320FED300DDB1D9 /* thread.h in Headers */, C3E273851FE4267D0026655E /* CatCrypto.h in Headers */, + C392E29B2320FED300DDB1D9 /* blake2-impl.h in Headers */, + C392E2932320FED300DDB1D9 /* blake2.h in Headers */, + C392E2C02320FEF500DDB1D9 /* argon2.h in Headers */, + C392E28F2320FED300DDB1D9 /* blamka-round-opt.h in Headers */, + C392E2B32320FED300DDB1D9 /* core.h in Headers */, + C392E28B2320FED300DDB1D9 /* blamka-round-ref.h in Headers */, + C392E2A72320FED300DDB1D9 /* encoding.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -703,22 +759,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C33EB1922320CF9C00988497 /* blake2b.c in Sources */, - C330B4C41FDE94E9005AEECC /* argon2.c in Sources */, - C330B4CB1FDE94E9005AEECC /* core.c in Sources */, - C330B4CD1FDE94E9005AEECC /* encoding.c in Sources */, - C330B4CF1FDE94E9005AEECC /* ref.c in Sources */, - C330B4D11FDE94E9005AEECC /* thread.c in Sources */, C367290C1FF4920E005BE1A8 /* SHA.swift in Sources */, + C392E2762320FED300DDB1D9 /* encoding.c in Sources */, C39EDD6D1FECF6F80081108F /* Helper.swift in Sources */, + C392E27A2320FED300DDB1D9 /* ref.c in Sources */, C31E52FC1FE906B2004C1F12 /* md6_mode.c in Sources */, C36729111FF496D4005BE1A8 /* Crypto.swift in Sources */, C3077C542010408F00407FDF /* ArrayExtension.swift in Sources */, + C392E29E2320FED300DDB1D9 /* core.c in Sources */, + C392E2AA2320FED300DDB1D9 /* argon2.c in Sources */, C3BDFE181FFE6D6300E060F6 /* KeccakSpongeWidth1600.c in Sources */, C39EDD771FECF9D00081108F /* Argon.swift in Sources */, C39EDD721FECF95C0081108F /* Verification.swift in Sources */, C3BDFE121FFE6C9400E060F6 /* SimpleFIPS202.c in Sources */, + C392E2BA2320FED300DDB1D9 /* thread.c in Sources */, C38A78F42003C01C0028D981 /* Encryption.swift in Sources */, + C392E2962320FED300DDB1D9 /* blake2b.c in Sources */, C3D6DD2A1FF39FFE0005C3D1 /* Contextual.swift in Sources */, C39EDD681FECF6440081108F /* Hashing.swift in Sources */, C39EDD7C1FECFB0B0081108F /* MessageDigest.swift in Sources */, @@ -734,22 +790,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C33EB1962320D54700988497 /* blake2b.c in Sources */, - C3E2738C1FE42B010026655E /* argon2.c in Sources */, - C3E2738E1FE42B010026655E /* core.c in Sources */, - C3E2738F1FE42B010026655E /* encoding.c in Sources */, - C3E273901FE42B010026655E /* ref.c in Sources */, - C3E273911FE42B010026655E /* thread.c in Sources */, C367290E1FF4920E005BE1A8 /* SHA.swift in Sources */, + C392E2782320FED300DDB1D9 /* encoding.c in Sources */, C39EDD6F1FECF6F80081108F /* Helper.swift in Sources */, + C392E27C2320FED300DDB1D9 /* ref.c in Sources */, C31E52FE1FE906B2004C1F12 /* md6_mode.c in Sources */, C36729131FF496D4005BE1A8 /* Crypto.swift in Sources */, C3077C562010408F00407FDF /* ArrayExtension.swift in Sources */, + C392E2A02320FED300DDB1D9 /* core.c in Sources */, + C392E2AC2320FED300DDB1D9 /* argon2.c in Sources */, C3BDFE1A1FFE6D6300E060F6 /* KeccakSpongeWidth1600.c in Sources */, C39EDD791FECF9D00081108F /* Argon.swift in Sources */, C39EDD741FECF95C0081108F /* Verification.swift in Sources */, C3BDFE141FFE6C9400E060F6 /* SimpleFIPS202.c in Sources */, + C392E2BC2320FED300DDB1D9 /* thread.c in Sources */, C38A78F62003C01C0028D981 /* Encryption.swift in Sources */, + C392E2982320FED300DDB1D9 /* blake2b.c in Sources */, C3D6DD2C1FF39FFE0005C3D1 /* Contextual.swift in Sources */, C39EDD6A1FECF6440081108F /* Hashing.swift in Sources */, C39EDD7E1FECFB0B0081108F /* MessageDigest.swift in Sources */, @@ -765,22 +821,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C33EB1972320D54F00988497 /* blake2b.c in Sources */, - C3E273921FE42B020026655E /* argon2.c in Sources */, - C3E273941FE42B020026655E /* core.c in Sources */, - C3E273951FE42B020026655E /* encoding.c in Sources */, - C3E273961FE42B020026655E /* ref.c in Sources */, - C3E273971FE42B020026655E /* thread.c in Sources */, C367290F1FF4920E005BE1A8 /* SHA.swift in Sources */, + C392E2792320FED300DDB1D9 /* encoding.c in Sources */, C39EDD701FECF6F80081108F /* Helper.swift in Sources */, + C392E27D2320FED300DDB1D9 /* ref.c in Sources */, C31E52FF1FE906B2004C1F12 /* md6_mode.c in Sources */, C36729141FF496D4005BE1A8 /* Crypto.swift in Sources */, C3077C572010408F00407FDF /* ArrayExtension.swift in Sources */, + C392E2A12320FED300DDB1D9 /* core.c in Sources */, + C392E2AD2320FED300DDB1D9 /* argon2.c in Sources */, C3BDFE1B1FFE6D6300E060F6 /* KeccakSpongeWidth1600.c in Sources */, C39EDD7A1FECF9D00081108F /* Argon.swift in Sources */, C39EDD751FECF95C0081108F /* Verification.swift in Sources */, C3BDFE151FFE6C9400E060F6 /* SimpleFIPS202.c in Sources */, + C392E2BD2320FED300DDB1D9 /* thread.c in Sources */, C38A78F72003C01C0028D981 /* Encryption.swift in Sources */, + C392E2992320FED300DDB1D9 /* blake2b.c in Sources */, C3D6DD2D1FF39FFE0005C3D1 /* Contextual.swift in Sources */, C39EDD6B1FECF6440081108F /* Hashing.swift in Sources */, C39EDD7F1FECFB0B0081108F /* MessageDigest.swift in Sources */, @@ -796,22 +852,22 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - C33EB1952320D4C000988497 /* blake2b.c in Sources */, - C3E273861FE42B000026655E /* argon2.c in Sources */, - C3E273881FE42B000026655E /* core.c in Sources */, - C3E273891FE42B000026655E /* encoding.c in Sources */, - C3E2738A1FE42B000026655E /* ref.c in Sources */, - C3E2738B1FE42B000026655E /* thread.c in Sources */, C367290D1FF4920E005BE1A8 /* SHA.swift in Sources */, + C392E2772320FED300DDB1D9 /* encoding.c in Sources */, C39EDD6E1FECF6F80081108F /* Helper.swift in Sources */, + C392E27B2320FED300DDB1D9 /* ref.c in Sources */, C31E52FD1FE906B2004C1F12 /* md6_mode.c in Sources */, C36729121FF496D4005BE1A8 /* Crypto.swift in Sources */, C3077C552010408F00407FDF /* ArrayExtension.swift in Sources */, + C392E29F2320FED300DDB1D9 /* core.c in Sources */, + C392E2AB2320FED300DDB1D9 /* argon2.c in Sources */, C3BDFE191FFE6D6300E060F6 /* KeccakSpongeWidth1600.c in Sources */, C39EDD781FECF9D00081108F /* Argon.swift in Sources */, C39EDD731FECF95C0081108F /* Verification.swift in Sources */, C3BDFE131FFE6C9400E060F6 /* SimpleFIPS202.c in Sources */, + C392E2BB2320FED300DDB1D9 /* thread.c in Sources */, C38A78F52003C01C0028D981 /* Encryption.swift in Sources */, + C392E2972320FED300DDB1D9 /* blake2b.c in Sources */, C3D6DD2B1FF39FFE0005C3D1 /* Contextual.swift in Sources */, C39EDD691FECF6440081108F /* Hashing.swift in Sources */, C39EDD7D1FECFB0B0081108F /* MessageDigest.swift in Sources */, diff --git a/CatCrypto.xcodeproj/xcshareddata/xcschemes/CommonCryptoModuleMap.xcscheme b/CatCrypto.xcodeproj/xcshareddata/xcschemes/CommonCryptoModuleMap.xcscheme new file mode 100644 index 0000000..cac95fa --- /dev/null +++ b/CatCrypto.xcodeproj/xcshareddata/xcschemes/CommonCryptoModuleMap.xcscheme @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Sources/ModuleMaps/Argon2/bench.c b/Sources/ModuleMaps/Argon2/bench.c deleted file mode 100755 index 20a2286..0000000 --- a/Sources/ModuleMaps/Argon2/bench.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include -#include -#include -#ifdef _MSC_VER -#include -#endif - -#include "argon2.h" - -static uint64_t rdtsc(void) { -#ifdef _MSC_VER - return __rdtsc(); -#else -#if defined(__amd64__) || defined(__x86_64__) - uint64_t rax, rdx; - __asm__ __volatile__("rdtsc" : "=a"(rax), "=d"(rdx) : :); - return (rdx << 32) | rax; -#elif defined(__i386__) || defined(__i386) || defined(__X86__) - uint64_t rax; - __asm__ __volatile__("rdtsc" : "=A"(rax) : :); - return rax; -#else -#error "Not implemented!" -#endif -#endif -} - -/* - * Benchmarks Argon2 with salt length 16, password length 16, t_cost 3, - and different m_cost and threads - */ -static void benchmark() { -#define BENCH_OUTLEN 16 -#define BENCH_INLEN 16 - const uint32_t inlen = BENCH_INLEN; - const unsigned outlen = BENCH_OUTLEN; - unsigned char out[BENCH_OUTLEN]; - unsigned char pwd_array[BENCH_INLEN]; - unsigned char salt_array[BENCH_INLEN]; -#undef BENCH_INLEN -#undef BENCH_OUTLEN - - uint32_t t_cost = 3; - uint32_t m_cost; - uint32_t thread_test[4] = {1, 2, 4, 8}; - argon2_type types[3] = {Argon2_i, Argon2_d, Argon2_id}; - - memset(pwd_array, 0, inlen); - memset(salt_array, 1, inlen); - - for (m_cost = (uint32_t)1 << 10; m_cost <= (uint32_t)1 << 22; m_cost *= 2) { - unsigned i; - for (i = 0; i < 4; ++i) { - double run_time = 0; - uint32_t thread_n = thread_test[i]; - - unsigned j; - for (j = 0; j < 3; ++j) { - clock_t start_time, stop_time; - uint64_t start_cycles, stop_cycles; - uint64_t delta; - double mcycles; - - argon2_type type = types[j]; - start_time = clock(); - start_cycles = rdtsc(); - - argon2_hash(t_cost, m_cost, thread_n, pwd_array, inlen, - salt_array, inlen, out, outlen, NULL, 0, type, - ARGON2_VERSION_NUMBER); - - stop_cycles = rdtsc(); - stop_time = clock(); - - delta = (stop_cycles - start_cycles) / (m_cost); - mcycles = (double)(stop_cycles - start_cycles) / (1UL << 20); - run_time += ((double)stop_time - start_time) / (CLOCKS_PER_SEC); - - printf("%s %d iterations %d MiB %d threads: %2.2f cpb %2.2f " - "Mcycles \n", argon2_type2string(type, 1), t_cost, - m_cost >> 10, thread_n, (float)delta / 1024, mcycles); - } - - printf("%2.4f seconds\n\n", run_time); - } - } -} - -int main() { - benchmark(); - return ARGON2_OK; -} diff --git a/Sources/ModuleMaps/Argon2/blake2.h b/Sources/ModuleMaps/Argon2/blake2.h index 89d8baa..57276a7 100755 --- a/Sources/ModuleMaps/Argon2/blake2.h +++ b/Sources/ModuleMaps/Argon2/blake2.h @@ -18,7 +18,7 @@ #ifndef PORTABLE_BLAKE2_H #define PORTABLE_BLAKE2_H -#include "argon2.h" +#include #if defined(__cplusplus) extern "C" { diff --git a/Sources/ModuleMaps/Argon2/genkat.c b/Sources/ModuleMaps/Argon2/genkat.c deleted file mode 100755 index 8db9036..0000000 --- a/Sources/ModuleMaps/Argon2/genkat.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include -#include "argon2.h" -#include "core.h" - -void initial_kat(const uint8_t *blockhash, const argon2_context *context, - argon2_type type) { - unsigned i; - - if (blockhash != NULL && context != NULL) { - printf("=======================================\n"); - - printf("%s version number %d\n", argon2_type2string(type, 1), - context->version); - - printf("=======================================\n"); - - - printf("Memory: %u KiB, Iterations: %u, Parallelism: %u lanes, Tag " - "length: %u bytes\n", - context->m_cost, context->t_cost, context->lanes, - context->outlen); - - printf("Password[%u]: ", context->pwdlen); - - if (context->flags & ARGON2_FLAG_CLEAR_PASSWORD) { - printf("CLEARED\n"); - } else { - for (i = 0; i < context->pwdlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->pwd)[i]); - } - - printf("\n"); - } - - printf("Salt[%u]: ", context->saltlen); - - for (i = 0; i < context->saltlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->salt)[i]); - } - - printf("\n"); - - printf("Secret[%u]: ", context->secretlen); - - if (context->flags & ARGON2_FLAG_CLEAR_SECRET) { - printf("CLEARED\n"); - } else { - for (i = 0; i < context->secretlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->secret)[i]); - } - - printf("\n"); - } - - printf("Associated data[%u]: ", context->adlen); - - for (i = 0; i < context->adlen; ++i) { - printf("%2.2x ", ((unsigned char *)context->ad)[i]); - } - - printf("\n"); - - printf("Pre-hashing digest: "); - - for (i = 0; i < ARGON2_PREHASH_DIGEST_LENGTH; ++i) { - printf("%2.2x ", ((unsigned char *)blockhash)[i]); - } - - printf("\n"); - } -} - -void print_tag(const void *out, uint32_t outlen) { - unsigned i; - if (out != NULL) { - printf("Tag: "); - - for (i = 0; i < outlen; ++i) { - printf("%2.2x ", ((uint8_t *)out)[i]); - } - - printf("\n"); - } -} - -void internal_kat(const argon2_instance_t *instance, uint32_t pass) { - - if (instance != NULL) { - uint32_t i, j; - printf("\n After pass %u:\n", pass); - - for (i = 0; i < instance->memory_blocks; ++i) { - uint32_t how_many_words = - (instance->memory_blocks > ARGON2_QWORDS_IN_BLOCK) - ? 1 - : ARGON2_QWORDS_IN_BLOCK; - - for (j = 0; j < how_many_words; ++j) - printf("Block %.4u [%3u]: %016llx\n", i, j, - (unsigned long long)instance->memory[i].v[j]); - } - } -} - -static void fatal(const char *error) { - fprintf(stderr, "Error: %s\n", error); - exit(1); -} - -static void generate_testvectors(argon2_type type, const uint32_t version) { -#define TEST_OUTLEN 32 -#define TEST_PWDLEN 32 -#define TEST_SALTLEN 16 -#define TEST_SECRETLEN 8 -#define TEST_ADLEN 12 - argon2_context context; - - unsigned char out[TEST_OUTLEN]; - unsigned char pwd[TEST_PWDLEN]; - unsigned char salt[TEST_SALTLEN]; - unsigned char secret[TEST_SECRETLEN]; - unsigned char ad[TEST_ADLEN]; - const allocate_fptr myown_allocator = NULL; - const deallocate_fptr myown_deallocator = NULL; - - unsigned t_cost = 3; - unsigned m_cost = 32; - unsigned lanes = 4; - - memset(pwd, 1, TEST_OUTLEN); - memset(salt, 2, TEST_SALTLEN); - memset(secret, 3, TEST_SECRETLEN); - memset(ad, 4, TEST_ADLEN); - - context.out = out; - context.outlen = TEST_OUTLEN; - context.version = version; - context.pwd = pwd; - context.pwdlen = TEST_PWDLEN; - context.salt = salt; - context.saltlen = TEST_SALTLEN; - context.secret = secret; - context.secretlen = TEST_SECRETLEN; - context.ad = ad; - context.adlen = TEST_ADLEN; - context.t_cost = t_cost; - context.m_cost = m_cost; - context.lanes = lanes; - context.threads = lanes; - context.allocate_cbk = myown_allocator; - context.free_cbk = myown_deallocator; - context.flags = ARGON2_DEFAULT_FLAGS; - -#undef TEST_OUTLEN -#undef TEST_PWDLEN -#undef TEST_SALTLEN -#undef TEST_SECRETLEN -#undef TEST_ADLEN - - argon2_ctx(&context, type); -} - -int main(int argc, char *argv[]) { - /* Get and check Argon2 type */ - const char *type_str = (argc > 1) ? argv[1] : "i"; - argon2_type type = Argon2_i; - uint32_t version = ARGON2_VERSION_NUMBER; - if (!strcmp(type_str, "d")) { - type = Argon2_d; - } else if (!strcmp(type_str, "i")) { - type = Argon2_i; - } else if (!strcmp(type_str, "id")) { - type = Argon2_id; - } else { - fatal("wrong Argon2 type"); - } - - /* Get and check Argon2 version number */ - if (argc > 2) { - version = strtoul(argv[2], NULL, 10); - } - if (ARGON2_VERSION_10 != version && ARGON2_VERSION_NUMBER != version) { - fatal("wrong Argon2 version number"); - } - - generate_testvectors(type, version); - return ARGON2_OK; -} diff --git a/Sources/ModuleMaps/Argon2/genkat.h b/Sources/ModuleMaps/Argon2/genkat.h deleted file mode 100755 index 0572630..0000000 --- a/Sources/ModuleMaps/Argon2/genkat.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#ifndef ARGON2_KAT_H -#define ARGON2_KAT_H - -#include "core.h" - -/* - * Initial KAT function that prints the inputs to the file - * @param blockhash Array that contains pre-hashing digest - * @param context Holds inputs - * @param type Argon2 type - * @pre blockhash must point to INPUT_INITIAL_HASH_LENGTH bytes - * @pre context member pointers must point to allocated memory of size according - * to the length values - */ -void initial_kat(const uint8_t *blockhash, const argon2_context *context, - argon2_type type); - -/* - * Function that prints the output tag - * @param out output array pointer - * @param outlen digest length - * @pre out must point to @a outlen bytes - **/ -void print_tag(const void *out, uint32_t outlen); - -/* - * Function that prints the internal state at given moment - * @param instance pointer to the current instance - * @param pass current pass number - * @pre instance must have necessary memory allocated - **/ -void internal_kat(const argon2_instance_t *instance, uint32_t pass); - -#endif diff --git a/Sources/ModuleMaps/Argon2/opt.c b/Sources/ModuleMaps/Argon2/opt.c deleted file mode 100755 index f6c2052..0000000 --- a/Sources/ModuleMaps/Argon2/opt.c +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include - -#include "argon2.h" -#include "core.h" - -#include "blake2/blake2.h" -#include "blake2/blamka-round-opt.h" - -/* - * Function fills a new memory block and optionally XORs the old block over the new one. - * Memory must be initialized. - * @param state Pointer to the just produced block. Content will be updated(!) - * @param ref_block Pointer to the reference block - * @param next_block Pointer to the block to be XORed over. May coincide with @ref_block - * @param with_xor Whether to XOR into the new block (1) or just overwrite (0) - * @pre all block pointers must be valid - */ -#if defined(__AVX512F__) -static void fill_block(__m512i *state, const block *ref_block, - block *next_block, int with_xor) { - __m512i block_XY[ARGON2_512BIT_WORDS_IN_BLOCK]; - unsigned int i; - - if (with_xor) { - for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { - state[i] = _mm512_xor_si512( - state[i], _mm512_loadu_si512((const __m512i *)ref_block->v + i)); - block_XY[i] = _mm512_xor_si512( - state[i], _mm512_loadu_si512((const __m512i *)next_block->v + i)); - } - } else { - for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { - block_XY[i] = state[i] = _mm512_xor_si512( - state[i], _mm512_loadu_si512((const __m512i *)ref_block->v + i)); - } - } - - for (i = 0; i < 2; ++i) { - BLAKE2_ROUND_1( - state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], state[8 * i + 3], - state[8 * i + 4], state[8 * i + 5], state[8 * i + 6], state[8 * i + 7]); - } - - for (i = 0; i < 2; ++i) { - BLAKE2_ROUND_2( - state[2 * 0 + i], state[2 * 1 + i], state[2 * 2 + i], state[2 * 3 + i], - state[2 * 4 + i], state[2 * 5 + i], state[2 * 6 + i], state[2 * 7 + i]); - } - - for (i = 0; i < ARGON2_512BIT_WORDS_IN_BLOCK; i++) { - state[i] = _mm512_xor_si512(state[i], block_XY[i]); - _mm512_storeu_si512((__m512i *)next_block->v + i, state[i]); - } -} -#elif defined(__AVX2__) -static void fill_block(__m256i *state, const block *ref_block, - block *next_block, int with_xor) { - __m256i block_XY[ARGON2_HWORDS_IN_BLOCK]; - unsigned int i; - - if (with_xor) { - for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { - state[i] = _mm256_xor_si256( - state[i], _mm256_loadu_si256((const __m256i *)ref_block->v + i)); - block_XY[i] = _mm256_xor_si256( - state[i], _mm256_loadu_si256((const __m256i *)next_block->v + i)); - } - } else { - for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { - block_XY[i] = state[i] = _mm256_xor_si256( - state[i], _mm256_loadu_si256((const __m256i *)ref_block->v + i)); - } - } - - for (i = 0; i < 4; ++i) { - BLAKE2_ROUND_1(state[8 * i + 0], state[8 * i + 4], state[8 * i + 1], state[8 * i + 5], - state[8 * i + 2], state[8 * i + 6], state[8 * i + 3], state[8 * i + 7]); - } - - for (i = 0; i < 4; ++i) { - BLAKE2_ROUND_2(state[ 0 + i], state[ 4 + i], state[ 8 + i], state[12 + i], - state[16 + i], state[20 + i], state[24 + i], state[28 + i]); - } - - for (i = 0; i < ARGON2_HWORDS_IN_BLOCK; i++) { - state[i] = _mm256_xor_si256(state[i], block_XY[i]); - _mm256_storeu_si256((__m256i *)next_block->v + i, state[i]); - } -} -#else -static void fill_block(__m128i *state, const block *ref_block, - block *next_block, int with_xor) { - __m128i block_XY[ARGON2_OWORDS_IN_BLOCK]; - unsigned int i; - - if (with_xor) { - for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { - state[i] = _mm_xor_si128( - state[i], _mm_loadu_si128((const __m128i *)ref_block->v + i)); - block_XY[i] = _mm_xor_si128( - state[i], _mm_loadu_si128((const __m128i *)next_block->v + i)); - } - } else { - for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { - block_XY[i] = state[i] = _mm_xor_si128( - state[i], _mm_loadu_si128((const __m128i *)ref_block->v + i)); - } - } - - for (i = 0; i < 8; ++i) { - BLAKE2_ROUND(state[8 * i + 0], state[8 * i + 1], state[8 * i + 2], - state[8 * i + 3], state[8 * i + 4], state[8 * i + 5], - state[8 * i + 6], state[8 * i + 7]); - } - - for (i = 0; i < 8; ++i) { - BLAKE2_ROUND(state[8 * 0 + i], state[8 * 1 + i], state[8 * 2 + i], - state[8 * 3 + i], state[8 * 4 + i], state[8 * 5 + i], - state[8 * 6 + i], state[8 * 7 + i]); - } - - for (i = 0; i < ARGON2_OWORDS_IN_BLOCK; i++) { - state[i] = _mm_xor_si128(state[i], block_XY[i]); - _mm_storeu_si128((__m128i *)next_block->v + i, state[i]); - } -} -#endif - -static void next_addresses(block *address_block, block *input_block) { - /*Temporary zero-initialized blocks*/ -#if defined(__AVX512F__) - __m512i zero_block[ARGON2_512BIT_WORDS_IN_BLOCK]; - __m512i zero2_block[ARGON2_512BIT_WORDS_IN_BLOCK]; -#elif defined(__AVX2__) - __m256i zero_block[ARGON2_HWORDS_IN_BLOCK]; - __m256i zero2_block[ARGON2_HWORDS_IN_BLOCK]; -#else - __m128i zero_block[ARGON2_OWORDS_IN_BLOCK]; - __m128i zero2_block[ARGON2_OWORDS_IN_BLOCK]; -#endif - - memset(zero_block, 0, sizeof(zero_block)); - memset(zero2_block, 0, sizeof(zero2_block)); - - /*Increasing index counter*/ - input_block->v[6]++; - - /*First iteration of G*/ - fill_block(zero_block, input_block, address_block, 0); - - /*Second iteration of G*/ - fill_block(zero2_block, address_block, address_block, 0); -} - -void fill_segment(const argon2_instance_t *instance, - argon2_position_t position) { - block *ref_block = NULL, *curr_block = NULL; - block address_block, input_block; - uint64_t pseudo_rand, ref_index, ref_lane; - uint32_t prev_offset, curr_offset; - uint32_t starting_index, i; -#if defined(__AVX512F__) - __m512i state[ARGON2_512BIT_WORDS_IN_BLOCK]; -#elif defined(__AVX2__) - __m256i state[ARGON2_HWORDS_IN_BLOCK]; -#else - __m128i state[ARGON2_OWORDS_IN_BLOCK]; -#endif - int data_independent_addressing; - - if (instance == NULL) { - return; - } - - data_independent_addressing = - (instance->type == Argon2_i) || - (instance->type == Argon2_id && (position.pass == 0) && - (position.slice < ARGON2_SYNC_POINTS / 2)); - - if (data_independent_addressing) { - init_block_value(&input_block, 0); - - input_block.v[0] = position.pass; - input_block.v[1] = position.lane; - input_block.v[2] = position.slice; - input_block.v[3] = instance->memory_blocks; - input_block.v[4] = instance->passes; - input_block.v[5] = instance->type; - } - - starting_index = 0; - - if ((0 == position.pass) && (0 == position.slice)) { - starting_index = 2; /* we have already generated the first two blocks */ - - /* Don't forget to generate the first block of addresses: */ - if (data_independent_addressing) { - next_addresses(&address_block, &input_block); - } - } - - /* Offset of the current block */ - curr_offset = position.lane * instance->lane_length + - position.slice * instance->segment_length + starting_index; - - if (0 == curr_offset % instance->lane_length) { - /* Last block in this lane */ - prev_offset = curr_offset + instance->lane_length - 1; - } else { - /* Previous block */ - prev_offset = curr_offset - 1; - } - - memcpy(state, ((instance->memory + prev_offset)->v), ARGON2_BLOCK_SIZE); - - for (i = starting_index; i < instance->segment_length; - ++i, ++curr_offset, ++prev_offset) { - /*1.1 Rotating prev_offset if needed */ - if (curr_offset % instance->lane_length == 1) { - prev_offset = curr_offset - 1; - } - - /* 1.2 Computing the index of the reference block */ - /* 1.2.1 Taking pseudo-random value from the previous block */ - if (data_independent_addressing) { - if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) { - next_addresses(&address_block, &input_block); - } - pseudo_rand = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK]; - } else { - pseudo_rand = instance->memory[prev_offset].v[0]; - } - - /* 1.2.2 Computing the lane of the reference block */ - ref_lane = ((pseudo_rand >> 32)) % instance->lanes; - - if ((position.pass == 0) && (position.slice == 0)) { - /* Can not reference other lanes yet */ - ref_lane = position.lane; - } - - /* 1.2.3 Computing the number of possible reference block within the - * lane. - */ - position.index = i; - ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF, - ref_lane == position.lane); - - /* 2 Creating a new block */ - ref_block = - instance->memory + instance->lane_length * ref_lane + ref_index; - curr_block = instance->memory + curr_offset; - if (ARGON2_VERSION_10 == instance->version) { - /* version 1.2.1 and earlier: overwrite, not XOR */ - fill_block(state, ref_block, curr_block, 0); - } else { - if(0 == position.pass) { - fill_block(state, ref_block, curr_block, 0); - } else { - fill_block(state, ref_block, curr_block, 1); - } - } - } -} diff --git a/Sources/ModuleMaps/Argon2/run.c b/Sources/ModuleMaps/Argon2/run.c deleted file mode 100755 index b21b9d7..0000000 --- a/Sources/ModuleMaps/Argon2/run.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#define _GNU_SOURCE 1 - -#include -#include -#include -#include -#include - -#include "argon2.h" -#include "core.h" - -#define T_COST_DEF 3 -#define LOG_M_COST_DEF 12 /* 2^12 = 4 MiB */ -#define LANES_DEF 1 -#define THREADS_DEF 1 -#define OUTLEN_DEF 32 -#define MAX_PASS_LEN 128 - -#define UNUSED_PARAMETER(x) (void)(x) - -static void usage(const char *cmd) { - printf("Usage: %s [-h] salt [-i|-d|-id] [-t iterations] " - "[-m log2(memory in KiB) | -k memory in KiB] [-p parallelism] " - "[-l hash length] [-e|-r] [-v (10|13)]\n", - cmd); - printf("\tPassword is read from stdin\n"); - printf("Parameters:\n"); - printf("\tsalt\t\tThe salt to use, at least 8 characters\n"); - printf("\t-i\t\tUse Argon2i (this is the default)\n"); - printf("\t-d\t\tUse Argon2d instead of Argon2i\n"); - printf("\t-id\t\tUse Argon2id instead of Argon2i\n"); - printf("\t-t N\t\tSets the number of iterations to N (default = %d)\n", - T_COST_DEF); - printf("\t-m N\t\tSets the memory usage of 2^N KiB (default %d)\n", - LOG_M_COST_DEF); - printf("\t-k N\t\tSets the memory usage of N KiB (default %d)\n", - 1 << LOG_M_COST_DEF); - printf("\t-p N\t\tSets parallelism to N threads (default %d)\n", - THREADS_DEF); - printf("\t-l N\t\tSets hash output length to N bytes (default %d)\n", - OUTLEN_DEF); - printf("\t-e\t\tOutput only encoded hash\n"); - printf("\t-r\t\tOutput only the raw bytes of the hash\n"); - printf("\t-v (10|13)\tArgon2 version (defaults to the most recent version, currently %x)\n", - ARGON2_VERSION_NUMBER); - printf("\t-h\t\tPrint %s usage\n", cmd); -} - -static void fatal(const char *error) { - fprintf(stderr, "Error: %s\n", error); - exit(1); -} - -static void print_hex(uint8_t *bytes, size_t bytes_len) { - size_t i; - for (i = 0; i < bytes_len; ++i) { - printf("%02x", bytes[i]); - } - printf("\n"); -} - -/* -Runs Argon2 with certain inputs and parameters, inputs not cleared. Prints the -Base64-encoded hash string -@out output array with at least 32 bytes allocated -@pwd NULL-terminated string, presumably from argv[] -@salt salt array -@t_cost number of iterations -@m_cost amount of requested memory in KB -@lanes amount of requested parallelism -@threads actual parallelism -@type Argon2 type we want to run -@encoded_only display only the encoded hash -@raw_only display only the hexadecimal of the hash -@version Argon2 version -*/ -static void run(uint32_t outlen, char *pwd, size_t pwdlen, char *salt, uint32_t t_cost, - uint32_t m_cost, uint32_t lanes, uint32_t threads, - argon2_type type, int encoded_only, int raw_only, uint32_t version) { - clock_t start_time, stop_time; - size_t saltlen, encodedlen; - int result; - unsigned char * out = NULL; - char * encoded = NULL; - - start_time = clock(); - - if (!pwd) { - fatal("password missing"); - } - - if (!salt) { - clear_internal_memory(pwd, pwdlen); - fatal("salt missing"); - } - - saltlen = strlen(salt); - if(UINT32_MAX < saltlen) { - fatal("salt is too long"); - } - - UNUSED_PARAMETER(lanes); - - out = malloc(outlen + 1); - if (!out) { - clear_internal_memory(pwd, pwdlen); - fatal("could not allocate memory for output"); - } - - encodedlen = argon2_encodedlen(t_cost, m_cost, lanes, (uint32_t)saltlen, outlen, type); - encoded = malloc(encodedlen + 1); - if (!encoded) { - clear_internal_memory(pwd, pwdlen); - fatal("could not allocate memory for hash"); - } - - result = argon2_hash(t_cost, m_cost, threads, pwd, pwdlen, salt, saltlen, - out, outlen, encoded, encodedlen, type, - version); - if (result != ARGON2_OK) - fatal(argon2_error_message(result)); - - stop_time = clock(); - - if (encoded_only) - puts(encoded); - - if (raw_only) - print_hex(out, outlen); - - if (encoded_only || raw_only) { - free(out); - free(encoded); - return; - } - - printf("Hash:\t\t"); - print_hex(out, outlen); - free(out); - - printf("Encoded:\t%s\n", encoded); - - printf("%2.3f seconds\n", - ((double)stop_time - start_time) / (CLOCKS_PER_SEC)); - - result = argon2_verify(encoded, pwd, pwdlen, type); - if (result != ARGON2_OK) - fatal(argon2_error_message(result)); - printf("Verification ok\n"); - free(encoded); -} - -int main(int argc, char *argv[]) { - uint32_t outlen = OUTLEN_DEF; - uint32_t m_cost = 1 << LOG_M_COST_DEF; - uint32_t t_cost = T_COST_DEF; - uint32_t lanes = LANES_DEF; - uint32_t threads = THREADS_DEF; - argon2_type type = Argon2_i; /* Argon2i is the default type */ - int types_specified = 0; - int m_cost_specified = 0; - int encoded_only = 0; - int raw_only = 0; - uint32_t version = ARGON2_VERSION_NUMBER; - int i; - size_t pwdlen; - char pwd[MAX_PASS_LEN], *salt; - - if (argc < 2) { - usage(argv[0]); - return ARGON2_MISSING_ARGS; - } else if (argc >= 2 && strcmp(argv[1], "-h") == 0) { - usage(argv[0]); - return 1; - } - - /* get password from stdin */ - pwdlen = fread(pwd, 1, sizeof pwd, stdin); - if(pwdlen < 1) { - fatal("no password read"); - } - if(pwdlen == MAX_PASS_LEN) { - fatal("Provided password longer than supported in command line utility"); - } - - salt = argv[1]; - - /* parse options */ - for (i = 2; i < argc; i++) { - const char *a = argv[i]; - unsigned long input = 0; - if (!strcmp(a, "-h")) { - usage(argv[0]); - return 1; - } else if (!strcmp(a, "-m")) { - if (m_cost_specified) { - fatal("-m or -k can only be used once"); - } - m_cost_specified = 1; - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - if (input == 0 || input == ULONG_MAX || - input > ARGON2_MAX_MEMORY_BITS) { - fatal("bad numeric input for -m"); - } - m_cost = ARGON2_MIN(UINT64_C(1) << input, UINT32_C(0xFFFFFFFF)); - if (m_cost > ARGON2_MAX_MEMORY) { - fatal("m_cost overflow"); - } - continue; - } else { - fatal("missing -m argument"); - } - } else if (!strcmp(a, "-k")) { - if (m_cost_specified) { - fatal("-m or -k can only be used once"); - } - m_cost_specified = 1; - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - if (input == 0 || input == ULONG_MAX) { - fatal("bad numeric input for -k"); - } - m_cost = ARGON2_MIN(input, UINT32_C(0xFFFFFFFF)); - if (m_cost > ARGON2_MAX_MEMORY) { - fatal("m_cost overflow"); - } - continue; - } else { - fatal("missing -k argument"); - } - } else if (!strcmp(a, "-t")) { - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - if (input == 0 || input == ULONG_MAX || - input > ARGON2_MAX_TIME) { - fatal("bad numeric input for -t"); - } - t_cost = input; - continue; - } else { - fatal("missing -t argument"); - } - } else if (!strcmp(a, "-p")) { - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - if (input == 0 || input == ULONG_MAX || - input > ARGON2_MAX_THREADS || input > ARGON2_MAX_LANES) { - fatal("bad numeric input for -p"); - } - threads = input; - lanes = threads; - continue; - } else { - fatal("missing -p argument"); - } - } else if (!strcmp(a, "-l")) { - if (i < argc - 1) { - i++; - input = strtoul(argv[i], NULL, 10); - outlen = input; - continue; - } else { - fatal("missing -l argument"); - } - } else if (!strcmp(a, "-i")) { - type = Argon2_i; - ++types_specified; - } else if (!strcmp(a, "-d")) { - type = Argon2_d; - ++types_specified; - } else if (!strcmp(a, "-id")) { - type = Argon2_id; - ++types_specified; - } else if (!strcmp(a, "-e")) { - encoded_only = 1; - } else if (!strcmp(a, "-r")) { - raw_only = 1; - } else if (!strcmp(a, "-v")) { - if (i < argc - 1) { - i++; - if (!strcmp(argv[i], "10")) { - version = ARGON2_VERSION_10; - } else if (!strcmp(argv[i], "13")) { - version = ARGON2_VERSION_13; - } else { - fatal("invalid Argon2 version"); - } - } else { - fatal("missing -v argument"); - } - } else { - fatal("unknown argument"); - } - } - - if (types_specified > 1) { - fatal("cannot specify multiple Argon2 types"); - } - - if(encoded_only && raw_only) - fatal("cannot provide both -e and -r"); - - if(!encoded_only && !raw_only) { - printf("Type:\t\t%s\n", argon2_type2string(type, 1)); - printf("Iterations:\t%u\n", t_cost); - printf("Memory:\t\t%u KiB\n", m_cost); - printf("Parallelism:\t%u\n", lanes); - } - - run(outlen, pwd, pwdlen, salt, t_cost, m_cost, lanes, threads, type, - encoded_only, raw_only, version); - - return ARGON2_OK; -} - diff --git a/Sources/ModuleMaps/Argon2/test.c b/Sources/ModuleMaps/Argon2/test.c deleted file mode 100755 index 3180cbd..0000000 --- a/Sources/ModuleMaps/Argon2/test.c +++ /dev/null @@ -1,289 +0,0 @@ -/* - * Argon2 reference source code package - reference C implementations - * - * Copyright 2015 - * Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves - * - * You may use this work under the terms of a Creative Commons CC0 1.0 - * License/Waiver or the Apache Public License 2.0, at your option. The terms of - * these licenses can be found at: - * - * - CC0 1.0 Universal : http://creativecommons.org/publicdomain/zero/1.0 - * - Apache 2.0 : http://www.apache.org/licenses/LICENSE-2.0 - * - * You should have received a copy of both of these licenses along with this - * software. If not, they may be obtained at the above URLs. - */ - -#include -#include -#include -#include -#include -#include - -#include "argon2.h" - -#define OUT_LEN 32 -#define ENCODED_LEN 108 - -/* Test harness will assert: - * argon2_hash() returns ARGON2_OK - * HEX output matches expected - * encoded output matches expected - * argon2_verify() correctly verifies value - */ - -void hashtest(uint32_t version, uint32_t t, uint32_t m, uint32_t p, char *pwd, - char *salt, char *hexref, char *mcfref, argon2_type type) { - unsigned char out[OUT_LEN]; - unsigned char hex_out[OUT_LEN * 2 + 4]; - char encoded[ENCODED_LEN]; - int ret, i; - - printf("Hash test: $v=%d t=%d, m=%d, p=%d, pass=%s, salt=%s: ", version, - t, m, p, pwd, salt); - - ret = argon2_hash(t, 1 << m, p, pwd, strlen(pwd), salt, strlen(salt), out, - OUT_LEN, encoded, ENCODED_LEN, type, version); - assert(ret == ARGON2_OK); - - for (i = 0; i < OUT_LEN; ++i) - sprintf((char *)(hex_out + i * 2), "%02x", out[i]); - assert(memcmp(hex_out, hexref, OUT_LEN * 2) == 0); - - if (ARGON2_VERSION_NUMBER == version) { - assert(memcmp(encoded, mcfref, strlen(mcfref)) == 0); - } - - ret = argon2_verify(encoded, pwd, strlen(pwd), type); - assert(ret == ARGON2_OK); - ret = argon2_verify(mcfref, pwd, strlen(pwd), type); - assert(ret == ARGON2_OK); - - printf("PASS\n"); -} - -int main() { - int ret; - unsigned char out[OUT_LEN]; - char const *msg; - int version; - - version = ARGON2_VERSION_10; - printf("Test Argon2i version number: %02x\n", version); - - /* Multiple test cases for various input values */ - hashtest(version, 2, 16, 1, "password", "somesalt", - "f6c4db4a54e2a370627aff3db6176b94a2a209a62c8e36152711802f7b30c694", - "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ" - "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ", Argon2_i); -#ifdef TEST_LARGE_RAM - hashtest(version, 2, 20, 1, "password", "somesalt", - "9690ec55d28d3ed32562f2e73ea62b02b018757643a2ae6e79528459de8106e9", - "$argon2i$m=1048576,t=2,p=1$c29tZXNhbHQ" - "$lpDsVdKNPtMlYvLnPqYrArAYdXZDoq5ueVKEWd6BBuk", Argon2_i); -#endif - hashtest(version, 2, 18, 1, "password", "somesalt", - "3e689aaa3d28a77cf2bc72a51ac53166761751182f1ee292e3f677a7da4c2467", - "$argon2i$m=262144,t=2,p=1$c29tZXNhbHQ" - "$Pmiaqj0op3zyvHKlGsUxZnYXURgvHuKS4/Z3p9pMJGc", Argon2_i); - hashtest(version, 2, 8, 1, "password", "somesalt", - "fd4dd83d762c49bdeaf57c47bdcd0c2f1babf863fdeb490df63ede9975fccf06", - "$argon2i$m=256,t=2,p=1$c29tZXNhbHQ" - "$/U3YPXYsSb3q9XxHvc0MLxur+GP960kN9j7emXX8zwY", Argon2_i); - hashtest(version, 2, 8, 2, "password", "somesalt", - "b6c11560a6a9d61eac706b79a2f97d68b4463aa3ad87e00c07e2b01e90c564fb", - "$argon2i$m=256,t=2,p=2$c29tZXNhbHQ" - "$tsEVYKap1h6scGt5ovl9aLRGOqOth+AMB+KwHpDFZPs", Argon2_i); - hashtest(version, 1, 16, 1, "password", "somesalt", - "81630552b8f3b1f48cdb1992c4c678643d490b2b5eb4ff6c4b3438b5621724b2", - "$argon2i$m=65536,t=1,p=1$c29tZXNhbHQ" - "$gWMFUrjzsfSM2xmSxMZ4ZD1JCytetP9sSzQ4tWIXJLI", Argon2_i); - hashtest(version, 4, 16, 1, "password", "somesalt", - "f212f01615e6eb5d74734dc3ef40ade2d51d052468d8c69440a3a1f2c1c2847b", - "$argon2i$m=65536,t=4,p=1$c29tZXNhbHQ" - "$8hLwFhXm6110c03D70Ct4tUdBSRo2MaUQKOh8sHChHs", Argon2_i); - hashtest(version, 2, 16, 1, "differentpassword", "somesalt", - "e9c902074b6754531a3a0be519e5baf404b30ce69b3f01ac3bf21229960109a3", - "$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ" - "$6ckCB0tnVFMaOgvlGeW69ASzDOabPwGsO/ISKZYBCaM", Argon2_i); - hashtest(version, 2, 16, 1, "password", "diffsalt", - "79a103b90fe8aef8570cb31fc8b22259778916f8336b7bdac3892569d4f1c497", - "$argon2i$m=65536,t=2,p=1$ZGlmZnNhbHQ" - "$eaEDuQ/orvhXDLMfyLIiWXeJFvgza3vaw4kladTxxJc", Argon2_i); - - /* Error state tests */ - - /* Handle an invalid encoding correctly (it is missing a $) */ - ret = argon2_verify("$argon2i$m=65536,t=2,p=1c29tZXNhbHQ" - "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_DECODING_FAIL); - printf("Recognise an invalid encoding: PASS\n"); - - /* Handle an invalid encoding correctly (it is missing a $) */ - ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ" - "9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_DECODING_FAIL); - printf("Recognise an invalid encoding: PASS\n"); - - /* Handle an invalid encoding correctly (salt is too short) */ - ret = argon2_verify("$argon2i$m=65536,t=2,p=1$" - "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_SALT_TOO_SHORT); - printf("Recognise an invalid salt in encoding: PASS\n"); - - /* Handle an mismatching hash (the encoded password is "passwore") */ - ret = argon2_verify("$argon2i$m=65536,t=2,p=1$c29tZXNhbHQ" - "$b2G3seW+uPzerwQQC+/E1K50CLLO7YXy0JRcaTuswRo", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_VERIFY_MISMATCH); - printf("Verify with mismatched password: PASS\n"); - - msg = argon2_error_message(ARGON2_DECODING_FAIL); - assert(strcmp(msg, "Decoding failed") == 0); - printf("Decode an error message: PASS\n"); - - printf("\n"); - - version = ARGON2_VERSION_NUMBER; - printf("Test Argon2i version number: %02x\n", version); - - /* Multiple test cases for various input values */ - hashtest(version, 2, 16, 1, "password", "somesalt", - "c1628832147d9720c5bd1cfd61367078729f6dfb6f8fea9ff98158e0d7816ed0", - "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ" - "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA", Argon2_i); -#ifdef TEST_LARGE_RAM - hashtest(version, 2, 20, 1, "password", "somesalt", - "d1587aca0922c3b5d6a83edab31bee3c4ebaef342ed6127a55d19b2351ad1f41", - "$argon2i$v=19$m=1048576,t=2,p=1$c29tZXNhbHQ" - "$0Vh6ygkiw7XWqD7asxvuPE667zQu1hJ6VdGbI1GtH0E", Argon2_i); -#endif - hashtest(version, 2, 18, 1, "password", "somesalt", - "296dbae80b807cdceaad44ae741b506f14db0959267b183b118f9b24229bc7cb", - "$argon2i$v=19$m=262144,t=2,p=1$c29tZXNhbHQ" - "$KW266AuAfNzqrUSudBtQbxTbCVkmexg7EY+bJCKbx8s", Argon2_i); - hashtest(version, 2, 8, 1, "password", "somesalt", - "89e9029f4637b295beb027056a7336c414fadd43f6b208645281cb214a56452f", - "$argon2i$v=19$m=256,t=2,p=1$c29tZXNhbHQ" - "$iekCn0Y3spW+sCcFanM2xBT63UP2sghkUoHLIUpWRS8", Argon2_i); - hashtest(version, 2, 8, 2, "password", "somesalt", - "4ff5ce2769a1d7f4c8a491df09d41a9fbe90e5eb02155a13e4c01e20cd4eab61", - "$argon2i$v=19$m=256,t=2,p=2$c29tZXNhbHQ" - "$T/XOJ2mh1/TIpJHfCdQan76Q5esCFVoT5MAeIM1Oq2E", Argon2_i); - hashtest(version, 1, 16, 1, "password", "somesalt", - "d168075c4d985e13ebeae560cf8b94c3b5d8a16c51916b6f4ac2da3ac11bbecf", - "$argon2i$v=19$m=65536,t=1,p=1$c29tZXNhbHQ" - "$0WgHXE2YXhPr6uVgz4uUw7XYoWxRkWtvSsLaOsEbvs8", Argon2_i); - hashtest(version, 4, 16, 1, "password", "somesalt", - "aaa953d58af3706ce3df1aefd4a64a84e31d7f54175231f1285259f88174ce5b", - "$argon2i$v=19$m=65536,t=4,p=1$c29tZXNhbHQ" - "$qqlT1YrzcGzj3xrv1KZKhOMdf1QXUjHxKFJZ+IF0zls", Argon2_i); - hashtest(version, 2, 16, 1, "differentpassword", "somesalt", - "14ae8da01afea8700c2358dcef7c5358d9021282bd88663a4562f59fb74d22ee", - "$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ" - "$FK6NoBr+qHAMI1jc73xTWNkCEoK9iGY6RWL1n7dNIu4", Argon2_i); - hashtest(version, 2, 16, 1, "password", "diffsalt", - "b0357cccfbef91f3860b0dba447b2348cbefecadaf990abfe9cc40726c521271", - "$argon2i$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ" - "$sDV8zPvvkfOGCw26RHsjSMvv7K2vmQq/6cxAcmxSEnE", Argon2_i); - - - /* Error state tests */ - - /* Handle an invalid encoding correctly (it is missing a $) */ - ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1c29tZXNhbHQ" - "$wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_DECODING_FAIL); - printf("Recognise an invalid encoding: PASS\n"); - - /* Handle an invalid encoding correctly (it is missing a $) */ - ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ" - "wWKIMhR9lyDFvRz9YTZweHKfbftvj+qf+YFY4NeBbtA", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_DECODING_FAIL); - printf("Recognise an invalid encoding: PASS\n"); - - /* Handle an invalid encoding correctly (salt is too short) */ - ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$" - "$9sTbSlTio3Biev89thdrlKKiCaYsjjYVJxGAL3swxpQ", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_SALT_TOO_SHORT); - printf("Recognise an invalid salt in encoding: PASS\n"); - - /* Handle an mismatching hash (the encoded password is "passwore") */ - ret = argon2_verify("$argon2i$v=19$m=65536,t=2,p=1$c29tZXNhbHQ" - "$8iIuixkI73Js3G1uMbezQXD0b8LG4SXGsOwoQkdAQIM", - "password", strlen("password"), Argon2_i); - assert(ret == ARGON2_VERIFY_MISMATCH); - printf("Verify with mismatched password: PASS\n"); - - msg = argon2_error_message(ARGON2_DECODING_FAIL); - assert(strcmp(msg, "Decoding failed") == 0); - printf("Decode an error message: PASS\n\n"); - - printf("Test Argon2id version number: %02x\n", version); - - /* Multiple test cases for various input values */ - hashtest(version, 2, 16, 1, "password", "somesalt", - "09316115d5cf24ed5a15a31a3ba326e5cf32edc24702987c02b6566f61913cf7", - "$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ" - "$CTFhFdXPJO1aFaMaO6Mm5c8y7cJHAph8ArZWb2GRPPc", Argon2_id); - hashtest(version, 2, 18, 1, "password", "somesalt", - "78fe1ec91fb3aa5657d72e710854e4c3d9b9198c742f9616c2f085bed95b2e8c", - "$argon2id$v=19$m=262144,t=2,p=1$c29tZXNhbHQ" - "$eP4eyR+zqlZX1y5xCFTkw9m5GYx0L5YWwvCFvtlbLow", Argon2_id); - hashtest(version, 2, 8, 1, "password", "somesalt", - "9dfeb910e80bad0311fee20f9c0e2b12c17987b4cac90c2ef54d5b3021c68bfe", - "$argon2id$v=19$m=256,t=2,p=1$c29tZXNhbHQ" - "$nf65EOgLrQMR/uIPnA4rEsF5h7TKyQwu9U1bMCHGi/4", Argon2_id); - hashtest(version, 2, 8, 2, "password", "somesalt", - "6d093c501fd5999645e0ea3bf620d7b8be7fd2db59c20d9fff9539da2bf57037", - "$argon2id$v=19$m=256,t=2,p=2$c29tZXNhbHQ" - "$bQk8UB/VmZZF4Oo79iDXuL5/0ttZwg2f/5U52iv1cDc", Argon2_id); - hashtest(version, 1, 16, 1, "password", "somesalt", - "f6a5adc1ba723dddef9b5ac1d464e180fcd9dffc9d1cbf76cca2fed795d9ca98", - "$argon2id$v=19$m=65536,t=1,p=1$c29tZXNhbHQ" - "$9qWtwbpyPd3vm1rB1GThgPzZ3/ydHL92zKL+15XZypg", Argon2_id); - hashtest(version, 4, 16, 1, "password", "somesalt", - "9025d48e68ef7395cca9079da4c4ec3affb3c8911fe4f86d1a2520856f63172c", - "$argon2id$v=19$m=65536,t=4,p=1$c29tZXNhbHQ" - "$kCXUjmjvc5XMqQedpMTsOv+zyJEf5PhtGiUghW9jFyw", Argon2_id); - hashtest(version, 2, 16, 1, "differentpassword", "somesalt", - "0b84d652cf6b0c4beaef0dfe278ba6a80df6696281d7e0d2891b817d8c458fde", - "$argon2id$v=19$m=65536,t=2,p=1$c29tZXNhbHQ" - "$C4TWUs9rDEvq7w3+J4umqA32aWKB1+DSiRuBfYxFj94", Argon2_id); - hashtest(version, 2, 16, 1, "password", "diffsalt", - "bdf32b05ccc42eb15d58fd19b1f856b113da1e9a5874fdcc544308565aa8141c", - "$argon2id$v=19$m=65536,t=2,p=1$ZGlmZnNhbHQ" - "$vfMrBczELrFdWP0ZsfhWsRPaHppYdP3MVEMIVlqoFBw", Argon2_id); - - /* Common error state tests */ - - printf("\n"); - printf("Common error state tests\n"); - - ret = argon2_hash(2, 1, 1, "password", strlen("password"), - "diffsalt", strlen("diffsalt"), - out, OUT_LEN, NULL, 0, Argon2_id, version); - assert(ret == ARGON2_MEMORY_TOO_LITTLE); - printf("Fail on invalid memory: PASS\n"); - - ret = argon2_hash(2, 1 << 12, 1, NULL, strlen("password"), - "diffsalt", strlen("diffsalt"), - out, OUT_LEN, NULL, 0, Argon2_id, version); - assert(ret == ARGON2_PWD_PTR_MISMATCH); - printf("Fail on invalid null pointer: PASS\n"); - - ret = argon2_hash(2, 1 << 12, 1, "password", strlen("password"), "s", 1, - out, OUT_LEN, NULL, 0, Argon2_id, version); - assert(ret == ARGON2_SALT_TOO_SHORT); - printf("Fail on salt too short: PASS\n"); - - return 0; -}