Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Salsa20 cipher and simplified ChaCha20 #717

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CryptoSwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@
E3FD2D531D6B81CE00A9F35F /* Error+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3FD2D511D6B813C00A9F35F /* Error+Extension.swift */; };
E6200E141FB9A7AE00258382 /* HKDF.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6200E131FB9A7AE00258382 /* HKDF.swift */; };
E6200E171FB9B68C00258382 /* HKDFTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6200E151FB9B67C00258382 /* HKDFTests.swift */; };
EBB32ABF22737C16003A065D /* Salsa20Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB51933F2268D600009CE32B /* Salsa20Tests.swift */; };
EBCE52E7226515AD00D8DAE7 /* Salsa20.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBCE52E6226515AD00D8DAE7 /* Salsa20.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -373,6 +375,8 @@
E3FD2D511D6B813C00A9F35F /* Error+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Error+Extension.swift"; sourceTree = "<group>"; };
E6200E131FB9A7AE00258382 /* HKDF.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HKDF.swift; sourceTree = "<group>"; };
E6200E151FB9B67C00258382 /* HKDFTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HKDFTests.swift; sourceTree = "<group>"; };
EB51933F2268D600009CE32B /* Salsa20Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Salsa20Tests.swift; sourceTree = "<group>"; };
EBCE52E6226515AD00D8DAE7 /* Salsa20.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Salsa20.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -500,6 +504,7 @@
75C2E76C1D55F097003D2BCA /* Access.swift */,
756BFDCA1A82B87300B9D9A4 /* Bridging.h */,
754BE46519693E190098E6F3 /* Supporting Files */,
EB51933F2268D600009CE32B /* Salsa20Tests.swift */,
);
name = Tests;
path = Tests/Tests;
Expand Down Expand Up @@ -615,6 +620,7 @@
75B3ED78210FA016005D4ADA /* BlockEncryptor.swift */,
753674062175D012003E32A6 /* StreamDecryptor.swift */,
756A64C52111083B00BE8805 /* StreamEncryptor.swift */,
EBCE52E6226515AD00D8DAE7 /* Salsa20.swift */,
);
path = CryptoSwift;
sourceTree = "<group>";
Expand Down Expand Up @@ -925,6 +931,7 @@
75EC52841EE8B8170048EB3B /* CipherModeWorker.swift in Sources */,
75EC52A41EE8B8290048EB3B /* Operators.swift in Sources */,
75EC529A1EE8B8200048EB3B /* HMAC+Foundation.swift in Sources */,
EBCE52E7226515AD00D8DAE7 /* Salsa20.swift in Sources */,
75EC52B21EE8B83D0048EB3B /* String+Extension.swift in Sources */,
750509991F6BEF2A00394A1B /* PKCS7.swift in Sources */,
75EC52B51EE8B83D0048EB3B /* UInt64+Extension.swift in Sources */,
Expand Down Expand Up @@ -978,6 +985,7 @@
758A94291A65C67400E46135 /* HMACTests.swift in Sources */,
75100F8F19B0BC890005C5F5 /* Poly1305Tests.swift in Sources */,
E6200E171FB9B68C00258382 /* HKDFTests.swift in Sources */,
EBB32ABF22737C16003A065D /* Salsa20Tests.swift in Sources */,
753B33011DAB84D600D06422 /* RandomBytesSequenceTests.swift in Sources */,
754BE46819693E190098E6F3 /* DigestTests.swift in Sources */,
E3FD2D531D6B81CE00A9F35F /* Error+Extension.swift in Sources */,
Expand Down
13 changes: 13 additions & 0 deletions CryptoSwift.xcodeproj/xcshareddata/xcschemes/Tests.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForRunning = "YES"
buildForTesting = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "754BE45F19693E190098E6F3"
BuildableName = "Tests.xctest"
BlueprintName = "Tests"
ReferencedContainer = "container:CryptoSwift.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForRunning = "YES"
buildForTesting = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7595C1492072E48C00EA1A5F"
BuildableName = "TestsPerformance-Mac.xctest"
BlueprintName = "TestsPerformance-Mac"
ReferencedContainer = "container:CryptoSwift.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Test"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
<BuildAction
parallelizeBuildables = "NO"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForRunning = "YES"
buildForTesting = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "7564F04E2072EAEB00CA5A96"
BuildableName = "TestsPerformance-iOS.xctest"
BlueprintName = "TestsPerformance-iOS"
ReferencedContainer = "container:CryptoSwift.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Test"
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Good mood

#### Cipher
[AES-128, AES-192, AES-256](http://csrc.nist.gov/publications/fips/fips197/fips-197.pdf)
| [Salsa20](https://cr.yp.to/snuffle/spec.pdf)
| [ChaCha20](http://cr.yp.to/chacha/chacha-20080128.pdf)
| [Rabbit](https://tools.ietf.org/html/rfc4503)
| [Blowfish](https://www.schneier.com/academic/blowfish/)
Expand Down Expand Up @@ -220,6 +221,7 @@ See: [Package.swift - manual](http://blog.krzyzanowskim.com/2016/08/09/package-s
* [Password-Based Key Derivation Function (PBKDF2, ...)](#password-based-key-derivation-functions)
* [HMAC-based Key Derivation Function (HKDF)](#hmac-based-key-derivation-function)
* [Data Padding](#data-padding)
* [Salsa20](#salsa20)
* [ChaCha20](#chacha20)
* [Rabbit](#rabbit)
* [Blowfish](#blowfish)
Expand Down Expand Up @@ -364,6 +366,13 @@ Padding.pkcs7.add(to: bytes, blockSize: AES.blockSize)
```

#### Working with Ciphers
##### Salsa20

```swift
let encrypted = try Salsa20(key: key, iv: iv).encrypt(message)
let decrypted = try Salsa20(key: key, iv: iv).decrypt(encrypted)
```

##### ChaCha20

```swift
Expand Down
Loading