Skip to content

Commit

Permalink
Update DarkStar.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
consuelita committed Dec 14, 2021
1 parent c5b680d commit d4f6c4e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Sources/ShadowSwift/DarkStar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ public struct DarkStar

static public func randomBytes(size: Int) -> Data
{
var data = Data(count: size)
_ = data.withUnsafeMutableBytes {
SecRandomCopyBytes(kSecRandomDefault, size, $0.baseAddress!)
var dataArray = [Data.Element]()

for _ in 1...size
{
let someInt = Int.random(in: 0 ..< 256)
dataArray.append(Data.Element(someInt))
}
return data

return Data(array: dataArray)
}

static public func generateServerConfirmationCode(clientSharedKey: SymmetricKey, endpoint: NWEndpoint, serverEphemeralPublicKey: P256.KeyAgreement.PublicKey, clientEphemeralPublicKey: P256.KeyAgreement.PublicKey) -> Data?
Expand Down

0 comments on commit d4f6c4e

Please sign in to comment.