|
@@ -53,13 +53,13 @@ Good mood
|
|
- Output Feedback ([OFB](http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Output_Feedback_.28OFB.29))
|
|
- Output Feedback ([OFB](http://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Output_Feedback_.28OFB.29))
|
|
- Counter ([CTR](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_.28CTR.29))
|
|
- Counter ([CTR](https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation#Counter_.28CTR.29))
|
|
|
|
|
|
|
|
+#####Password-Based Key Derivation Function
|
|
|
|
+- [PBKDF2](http://tools.ietf.org/html/rfc2898#section-5.2) (Password-Based Key Derivation Function 2)
|
|
|
|
+
|
|
#####Data padding
|
|
#####Data padding
|
|
- [PKCS#7](http://tools.ietf.org/html/rfc5652#section-6.3)
|
|
- [PKCS#7](http://tools.ietf.org/html/rfc5652#section-6.3)
|
|
- NoPadding
|
|
- NoPadding
|
|
|
|
|
|
-#####Password-Based Key Derivation Function
|
|
|
|
-- [PBKDF2](http://tools.ietf.org/html/rfc2898#section-5.2) (Password-Based Key Derivation Function 2)
|
|
|
|
-
|
|
|
|
##Why
|
|
##Why
|
|
[Why?](https://github.com/krzyzanowskim/CryptoSwift/issues/5) [Because I can](https://github.com/krzyzanowskim/CryptoSwift/issues/5#issuecomment-53379391).
|
|
[Why?](https://github.com/krzyzanowskim/CryptoSwift/issues/5) [Because I can](https://github.com/krzyzanowskim/CryptoSwift/issues/5#issuecomment-53379391).
|
|
|
|
|
|
@@ -196,6 +196,16 @@ let mac: [UInt8] = try! Authenticator.Poly1305(key: key).authenticate(message)
|
|
let hmac: [UInt8] = try! Authenticator.HMAC(key: key, variant: .sha256).authenticate(message)
|
|
let hmac: [UInt8] = try! Authenticator.HMAC(key: key, variant: .sha256).authenticate(message)
|
|
```
|
|
```
|
|
|
|
|
|
|
|
+#####Password-Based Key Derivation Function
|
|
|
|
+
|
|
|
|
+```swift
|
|
|
|
+let password: [UInt8] = "s33krit".utf8.map {$0}
|
|
|
|
+let salt: [UInt8] = "nacl".utf8.map {$0}
|
|
|
|
+
|
|
|
|
+let value = try! PKCS5.PBKDF2(password: password, salt: salt, iterations: 4096, hashVariant: .sha256).calculate()
|
|
|
|
+value.toHexString() // print Hex representation
|
|
|
|
+```
|
|
|
|
+
|
|
#####Data Padding
|
|
#####Data Padding
|
|
|
|
|
|
Some content-encryption algorithms assume the input length is a multiple of k octets, where k is greater than one. For such algorithms, the input shall be padded.
|
|
Some content-encryption algorithms assume the input length is a multiple of k octets, where k is greater than one. For such algorithms, the input shall be padded.
|