diff --git a/Sources/SRP/Array.swift b/Sources/SRP/Array.swift index 8f2a181..0061ac5 100644 --- a/Sources/SRP/Array.swift +++ b/Sources/SRP/Array.swift @@ -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") diff --git a/Sources/SRP/srp.swift b/Sources/SRP/srp.swift index b4dce89..b923ea6 100644 --- a/Sources/SRP/srp.swift +++ b/Sources/SRP/srp.swift @@ -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 {