Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ticesoftware/hkdf
Provides a HKDF based on libsodium via swift-sodium
https://github.com/ticesoftware/hkdf
swift tice-app tice-crypto
Last synced: about 1 month ago
JSON representation
Provides a HKDF based on libsodium via swift-sodium
- Host: GitHub
- URL: https://github.com/ticesoftware/hkdf
- Owner: TICESoftware
- License: mit
- Created: 2019-05-05T09:43:34.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-01T12:40:46.000Z (over 3 years ago)
- Last Synced: 2024-11-14T01:02:34.483Z (about 1 month ago)
- Topics: swift, tice-app, tice-crypto
- Language: Swift
- Homepage:
- Size: 15.6 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HKDF
HMAC-based Extract-and-Expand Key Derivation Function (HKDF) as defined in RFC 5869.
The HMAC is provided by libsodium which uses the HMAC-SHA-512/256 algorithm.## Installation
### SPM
`.package(url: "https://github.com/TICESoftware/HKDF.git", .upToNextMajor(from: "1.0.0"))`In order to build the library it is necessary to link libsodium. The official repository includes scripts to build binaries for specific platforms.
`swift build -Xcc -I[header search path] -Xlinker -L[binary path]`
When using Xcode you can set the header search path manually to include the libsodium header files and link the static libsodium library.
### CodoaPods
`pod 'HKDF'`This uses `Sodium` as a dependency which includes the pre-compiled libsodium library. No further setup necessary.
## Usage
For deriving a new key of length 32 bytes from some input keying material `ikm`:```swift
import HKDFlet ikm = "Input key".bytes
let hkdfKey = try! deriveHKDFKey(ikm: ikm, L: 32)
```A `salt` and some application specific info string (which is hashed into the HMAC) can additionally be provided:
`try deriveHKDFKey(ikm: ikm, salt: salt, info: "Info", L: 32)`