keycardExportKey returns priv/pub key
This commit is contained in:
parent
089413e6bf
commit
b602caf727
|
@ -19,7 +19,7 @@ method keycardOpenSecureChannel*(self: Backend, index: int, key: string) =
|
|||
method keycardVerifyPin*(self: Backend, pin: string) =
|
||||
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")
|
||||
|
||||
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 keycardExportKey*(self: MockBackend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): string =
|
||||
result = "0x00"
|
||||
method keycardExportKey*(self: MockBackend, derive: bool, makeCurrent: bool, onlyPublic: bool, path: string): KeycardExportedKey =
|
||||
result = KeycardExportedKey()
|
||||
|
||||
method keycardGetStatusApplication*(self: MockBackend): KeycardStatus =
|
||||
result = KeycardStatus()
|
||||
|
|
|
@ -67,7 +67,7 @@ method keycardVerifyPin*(self: StatusGoBackend, pin: string) =
|
|||
if not parsedResponse{"ok"}.getBool():
|
||||
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 = %* {
|
||||
"derive": derive,
|
||||
"makeCurrent": makeCurrent,
|
||||
|
@ -79,7 +79,10 @@ method keycardExportKey*(self: StatusGoBackend, derive: bool, makeCurrent: bool,
|
|||
if not parsedResponse{"ok"}.getBool():
|
||||
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 =
|
||||
let response = keycard_go.getStatusApplication()
|
||||
|
|
|
@ -47,7 +47,7 @@ proc verifyPin*(self: KeycardModel, pin: string) =
|
|||
except:
|
||||
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:
|
||||
result = self.backend.keycardExportKey(derive, makeCurrent, onlyPublic, path)
|
||||
except:
|
||||
|
|
|
@ -41,3 +41,8 @@ type KeycardStatus* = ref object
|
|||
pukRetryCount *: int64
|
||||
keyInitialized*: bool
|
||||
path*: string
|
||||
|
||||
type KeycardExportedKey* = ref object
|
||||
privKey*: string
|
||||
pubKey*: string
|
||||
|
||||
|
|
Loading…
Reference in New Issue