V0.6.9 Arroyo Toad
Added support for P256 Curve and suppressed support for P521 Curve that will be reimplemented later
This commit is contained in:
@@ -29,7 +29,7 @@ import Testing
|
||||
messageType: .KEEPALIVE,
|
||||
devType: .EDGE_SENSOR,
|
||||
RESERVED: 0,
|
||||
signType: .P521,
|
||||
signType: .P256,
|
||||
timestamp: Date(),
|
||||
devID: 1,
|
||||
location: Location(x: 10, y: 20, z: 1),
|
||||
@@ -43,8 +43,8 @@ import Testing
|
||||
|
||||
}
|
||||
@Test func serializeDeserializeMessage() async throws {
|
||||
let keyPath = "./Private/privateKey.pem"
|
||||
let key = try pem2key(filePath: keyPath)
|
||||
let keyPath = "./Private/privateKey256.pem"
|
||||
let key = try pem2_P256key(filePath: keyPath)
|
||||
let publicKey = key.publicKey
|
||||
|
||||
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||
@@ -53,7 +53,7 @@ import Testing
|
||||
messageType: .KEEPALIVE,
|
||||
devType: .EDGE_SENSOR,
|
||||
RESERVED: 0,
|
||||
signType: .P521,
|
||||
signType: .P256,
|
||||
timestamp: Date(),
|
||||
devID: 1,
|
||||
location: Location(x: 10, y: 20, z: 1),
|
||||
@@ -92,21 +92,22 @@ import Testing
|
||||
@Test func serializeMessageForLaterUse() async throws {
|
||||
// Write your test here and use APIs like `#expect(...)` to check expected conditions.
|
||||
|
||||
let keyPath = "./Private/privateKey.pem"
|
||||
let key = try pem2key(filePath: keyPath)
|
||||
let keyPath = "./Private/privateKey256.pem"
|
||||
let key = try pem2_P256key(filePath: keyPath)
|
||||
|
||||
let msg = Message(
|
||||
version: 1,
|
||||
messageType: .KEEPALIVE,
|
||||
devType: .EDGE_SENSOR,
|
||||
RESERVED: 0,
|
||||
signType: .P521,
|
||||
signType: .P256,
|
||||
timestamp: Date(),
|
||||
devID: 1,
|
||||
devID: 120,
|
||||
location: Location(x: 10, y: 20, z: 1),
|
||||
fields: [
|
||||
Field(key: Array("valueOfLife".utf8), value: Array("42".utf8)),
|
||||
Field(key: Array("Live Love".utf8), value: Array("Laugh".utf8)),
|
||||
Field(key: Array("Covfefe".utf8), value: Array("1.20f".utf8)),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -116,6 +117,6 @@ import Testing
|
||||
data.append(Data(signature))
|
||||
|
||||
try data.write(to: URL(filePath: "./Private/signedMessage/Message.bin"))
|
||||
try key.publicKey.pemRepresentation.write(to: URL(filePath: "./Private/signedMessage/public-key.pem"), atomically: true, encoding: String.Encoding.utf8)
|
||||
try key.publicKey.pemRepresentation.write(to: URL(filePath: "./Private/signedMessage/public-key256.pem"), atomically: true, encoding: String.Encoding.utf8)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user