mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-03 22:43:09 +00:00
fix: remove trailing commas from keystore json (#2200)
* fix: remove trailing commas from keystore json * keyfile.nim: try a different Json formatting approach * build keystore * address comment --------- Co-authored-by: Ivan Folgueira Bande <ivansete@status.im>
This commit is contained in:
parent
a0eb05ea19
commit
0f3cf94ac2
@ -92,6 +92,23 @@ type
|
|||||||
DKey = array[DKLen, byte]
|
DKey = array[DKLen, byte]
|
||||||
KfResult*[T] = Result[T, KeyFileError]
|
KfResult*[T] = Result[T, KeyFileError]
|
||||||
|
|
||||||
|
# basic types for building Keystore JSON
|
||||||
|
CypherParams = object
|
||||||
|
iv: string
|
||||||
|
|
||||||
|
CryptoNew = object
|
||||||
|
cipher: string
|
||||||
|
cipherparams: CypherParams
|
||||||
|
ciphertext: string
|
||||||
|
kdf: string
|
||||||
|
kdfparams: JsonNode
|
||||||
|
mac: string
|
||||||
|
|
||||||
|
KeystoreEntry = object
|
||||||
|
crypto: CryptoNew
|
||||||
|
id: string
|
||||||
|
version: string
|
||||||
|
|
||||||
const
|
const
|
||||||
SupportedHashes = [
|
SupportedHashes = [
|
||||||
"sha224", "sha256", "sha384", "sha512",
|
"sha224", "sha256", "sha384", "sha512",
|
||||||
@ -373,20 +390,20 @@ proc createKeyFileJson*(secret: openArray[byte],
|
|||||||
|
|
||||||
let params = ? kdfParams(kdfkind, toHex(salt, true), workfactor)
|
let params = ? kdfParams(kdfkind, toHex(salt, true), workfactor)
|
||||||
|
|
||||||
let json = %*
|
var obj = KeystoreEntry(
|
||||||
{
|
crypto: CryptoNew(
|
||||||
"crypto": {
|
cipher: $cryptkind,
|
||||||
"cipher": $cryptkind,
|
cipherparams: CypherParams(
|
||||||
"cipherparams": {
|
iv: toHex(iv, true)
|
||||||
"iv": toHex(iv, true)
|
),
|
||||||
},
|
ciphertext: toHex(ciphertext, true),
|
||||||
"ciphertext": toHex(ciphertext, true),
|
kdf: $kdfkind,
|
||||||
"kdf": $kdfkind,
|
kdfparams: params,
|
||||||
"kdfparams": params,
|
mac: toHex(mac.data, true)
|
||||||
"mac": toHex(mac.data, true),
|
)
|
||||||
},
|
)
|
||||||
}
|
|
||||||
|
|
||||||
|
let json = %* obj
|
||||||
if IdInKeyfile:
|
if IdInKeyfile:
|
||||||
json.add("id", %($u))
|
json.add("id", %($u))
|
||||||
if VersionInKeyfile:
|
if VersionInKeyfile:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user