Skip to content

Commit

Permalink
Move Array.pad
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-fowler committed Oct 29, 2024
1 parent cd494c3 commit b0b2f33
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 10 additions & 0 deletions Sources/SRP/Array.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ extension Array where Element: FixedWidthInteger {
}
}

extension Array where Element == UInt8 {
func pad(to size: Int) -> [UInt8] {
let padSize = size - self.count
guard padSize > 0 else { return self }
// create prefix and return prefix + data
let prefix: [UInt8] = (1...padSize).reduce([]) { result,_ in return result + [0] }
return prefix + self
}
}

/// xor together the contents of two byte arrays
func ^ (lhs: [UInt8], rhs: [UInt8]) -> [UInt8] {
precondition(lhs.count == rhs.count, "Arrays are required to be the same size")
Expand Down
10 changes: 0 additions & 10 deletions Sources/SRP/srp.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import BigNum
import Crypto

extension Array where Element == UInt8 {
func pad(to size: Int) -> [UInt8] {
let padSize = size - self.count
guard padSize > 0 else { return self }
// create prefix and return prefix + data
let prefix: [UInt8] = (1...padSize).reduce([]) { result,_ in return result + [0] }
return prefix + self
}
}

/// Contains common code used by both client and server SRP code
public struct SRP<H: HashFunction> {

Expand Down

0 comments on commit b0b2f33

Please sign in to comment.