keycardExportKey returns priv/pub key
This commit is contained in:
parent
387fab7296
commit
8d449ac5df
|
@ -19,7 +19,7 @@ method keycardOpenSecureChannel*(self: Backend, index: int, key: string) =
|
||||||
method keycardVerifyPin*(self: Backend, pin: string) =
|
method keycardVerifyPin*(self: Backend, pin: string) =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method keycardExportKey*(self: Backend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): string =
|
method keycardExportKey*(self: Backend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): KeycardExportedKey =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method keycardGetStatusApplication*(self: Backend): KeycardStatus =
|
method keycardGetStatusApplication*(self: Backend): KeycardStatus =
|
||||||
|
|
|
@ -15,8 +15,8 @@ method keycardOpenSecureChannel*(self: MockBackend, index: int, key: string) = d
|
||||||
|
|
||||||
method keycardVerifyPin*(self: MockBackend, pin: string) = discard
|
method keycardVerifyPin*(self: MockBackend, pin: string) = discard
|
||||||
|
|
||||||
method keycardExportKey*(self: MockBackend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): string =
|
method keycardExportKey*(self: MockBackend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): KeycardExportedKey =
|
||||||
result = "0x00"
|
result = KeycardExportedKey()
|
||||||
|
|
||||||
method keycardGetStatusApplication*(self: MockBackend): KeycardStatus =
|
method keycardGetStatusApplication*(self: MockBackend): KeycardStatus =
|
||||||
result = KeycardStatus()
|
result = KeycardStatus()
|
||||||
|
|
|
@ -67,7 +67,7 @@ method keycardVerifyPin*(self: StatusGoBackend, pin: string) =
|
||||||
if not parsedResponse{"ok"}.getBool():
|
if not parsedResponse{"ok"}.getBool():
|
||||||
raise KeycardVerifyPINException(error: parsedResponse{"error"}.getStr())
|
raise KeycardVerifyPINException(error: parsedResponse{"error"}.getStr())
|
||||||
|
|
||||||
method keycardExportKey*(self: StatusGoBackend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): string =
|
method keycardExportKey*(self: StatusGoBackend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): KeycardExportedKey =
|
||||||
let inputJSON = %* {
|
let inputJSON = %* {
|
||||||
"derive": derive,
|
"derive": derive,
|
||||||
"makeCurrent": makeCurrent,
|
"makeCurrent": makeCurrent,
|
||||||
|
@ -79,7 +79,10 @@ method keycardExportKey*(self: StatusGoBackend, derive: bool, makeCurrent: bool,
|
||||||
if not parsedResponse{"ok"}.getBool():
|
if not parsedResponse{"ok"}.getBool():
|
||||||
raise KeycardSelectException(error: parsedResponse{"error"}.getStr())
|
raise KeycardSelectException(error: parsedResponse{"error"}.getStr())
|
||||||
|
|
||||||
result = parsedResponse["key"].getStr()
|
result = KeycardExportedKey(
|
||||||
|
privKey: parsedResponse["privateKey"].getStr(),
|
||||||
|
pubKey: parsedResponse["publicKey"].getStr()
|
||||||
|
)
|
||||||
|
|
||||||
method keycardGetStatusApplication*(self: StatusGoBackend): KeycardStatus =
|
method keycardGetStatusApplication*(self: StatusGoBackend): KeycardStatus =
|
||||||
let response = keycard_go.getStatusApplication()
|
let response = keycard_go.getStatusApplication()
|
||||||
|
|
|
@ -47,7 +47,7 @@ proc verifyPin*(self: KeycardModel, pin: string) =
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
proc exportKey*(self: KeycardModel, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): string =
|
proc exportKey*(self: KeycardModel, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): KeycardExportedKey =
|
||||||
try:
|
try:
|
||||||
result = self.backend.keycardExportKey(derive, makeCurrent, onlyPublic, path)
|
result = self.backend.keycardExportKey(derive, makeCurrent, onlyPublic, path)
|
||||||
except:
|
except:
|
||||||
|
|
|
@ -41,3 +41,8 @@ type KeycardStatus* = ref object
|
||||||
pukRetryCount *: int64
|
pukRetryCount *: int64
|
||||||
keyInitialized*: bool
|
keyInitialized*: bool
|
||||||
path*: string
|
path*: string
|
||||||
|
|
||||||
|
type KeycardExportedKey* = ref object
|
||||||
|
privKey*: string
|
||||||
|
pubKey*: string
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue