Add tests for Keystore with missing description.

This commit is contained in:
cheatfate 2022-08-15 13:49:15 +03:00
parent 9e6d9b955d
commit d10b71d6c1
No known key found for this signature in database
GPG Key ID: 46ADD633A7201F95
1 changed files with 81 additions and 0 deletions

View File

@ -59,6 +59,38 @@ const
"version": 4
}"""
scryptVector2 = """{
"crypto": {
"kdf": {
"function": "scrypt",
"params": {
"dklen": 32,
"n": 262144,
"p": 1,
"r": 8,
"salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
},
"message": ""
},
"checksum": {
"function": "sha256",
"params": {},
"message": "d2217fe5f3e9a1e34581ef8a78f7c9928e436d36dacc5e846690a5581e8ea484"
},
"cipher": {
"function": "aes-128-ctr",
"params": {
"iv": "264daa3f303d7259501c93d997d84fe6"
},
"message": "06ae90d55fe0a6e9c5c3bc5b170827b2e5cce3929ed3f116c2811e6366dfe20f"
}
},
"pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07",
"path": "m/12381/60/3141592653/589793238",
"uuid": "1d85ae20-35c5-4611-98e8-aa14a633906f",
"version": 4
}"""
pbkdf2Vector = """{
"crypto": {
"kdf": {
@ -91,6 +123,37 @@ const
"version": 4
}"""
pbkdf2Vector2 = """{
"crypto": {
"kdf": {
"function": "pbkdf2",
"params": {
"dklen": 32,
"c": 262144,
"prf": "hmac-sha256",
"salt": "d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
},
"message": ""
},
"checksum": {
"function": "sha256",
"params": {},
"message": "8a9f5d9912ed7e75ea794bc5a89bca5f193721d30868ade6f73043c6ea6febf1"
},
"cipher": {
"function": "aes-128-ctr",
"params": {
"iv": "264daa3f303d7259501c93d997d84fe6"
},
"message": "cee03fde2af33149775b7223e7845e4fb2c8ae1792e5f99fe9ecf474cc8c16ad"
}
},
"pubkey": "9612d7a727c9d0a22e185a1c768478dfe919cada9266988cb32359c11f2b7b27f4ae4040902382ae2910c15e2b420d07",
"path": "m/12381/60/0/0",
"uuid": "64625def-3331-4eea-ab6f-782f3ed16a83",
"version": 4
}"""
pbkdf2NetVector = """{
"crypto":{
"kdf":{
@ -179,6 +242,15 @@ suite "KeyStorage testing suite":
check decrypt.isOk
check secret.isEqual(decrypt.get())
test "[PBKDF2] Keystore decryption (requireAllFields, allowUnknownFields)":
let
keystore = Json.decode(pbkdf2Vector2, Keystore, requireAllFields = true,
allowUnknownFields = true)
decrypt = decryptKeystore(keystore, KeystorePass.init password)
check decrypt.isOk
check secret.isEqual(decrypt.get())
test "[SCRYPT] Keystore decryption":
let
keystore = Json.decode(scryptVector, Keystore)
@ -187,6 +259,15 @@ suite "KeyStorage testing suite":
check decrypt.isOk
check secret.isEqual(decrypt.get())
test "[SCRYPT] Keystore decryption (requireAllFields, allowUnknownFields)":
let
keystore = Json.decode(pbkdf2Vector2, Keystore, requireAllFields = true,
allowUnknownFields = true)
decrypt = decryptKeystore(keystore, KeystorePass.init password)
check decrypt.isOk
check secret.isEqual(decrypt.get())
test "[PBKDF2] Network Keystore decryption":
let
keystore = Json.decode(pbkdf2NetVector, NetKeystore)