mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-08-31 01:20:57 +00:00
* WIP. * WIP * WIP Edit * Key selection. * WIP * WIP * Proxy through * WIP * Remove verify. * Migration. * Comment * Add param * Semi-offering key * Ignore updates if test build. * Fix rsa public key gen * Messily fix RSA * Remove 1024 bit rsa * Cleanup * Cleanup * Clean out MLDSA refs for now * Dump notifier changes * Put back UI tweaks * Fixes.
29 lines
857 B
Swift
29 lines
857 B
Swift
import Foundation
|
|
|
|
/// Reads OpenSSH protocol data.
|
|
public final class OpenSSHReader {
|
|
|
|
var remaining: Data
|
|
|
|
/// Initialize the reader with an OpenSSH data payload.
|
|
/// - Parameter data: The data to read.
|
|
public init(data: Data) {
|
|
remaining = Data(data)
|
|
}
|
|
|
|
/// Reads the next chunk of data from the playload.
|
|
/// - Returns: The next chunk of data.
|
|
public func readNextChunk() -> Data {
|
|
let lengthRange = 0..<(UInt32.bitWidth/8)
|
|
let lengthChunk = remaining[lengthRange]
|
|
remaining.removeSubrange(lengthRange)
|
|
let littleEndianLength = lengthChunk.bytes.unsafeLoad(as: UInt32.self)
|
|
let length = Int(littleEndianLength.bigEndian)
|
|
let dataRange = 0..<length
|
|
let ret = Data(remaining[dataRange])
|
|
remaining.removeSubrange(dataRange)
|
|
return ret
|
|
}
|
|
|
|
}
|