Swiftpack.co -  TICESoftware/HKDF as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
TICESoftware/HKDF
Provides a HKDF based on libsodium via swift-sodium
.package(url: "https://github.com/TICESoftware/HKDF.git", from: "1.0.10")

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:

import HKDF

let 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)

GitHub

link
Stars: 2
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Related Packages

Release Notes

2 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API