Module libu2f_server

Error codes:

OK: Success. MEMORY_ERROR: Memory error. JSON_ERROR: Json error. BASE64_ERROR: Base64 error. CRYPTO_ERROR: Cryptographic error. ORIGIN_ERROR: Origin mismatch. CHALLENGE_ERROR: Challenge error. SIGNATURE_ERROR: Signature mismatch. FORMAT_ERROR: Message format error.

Types

u2fs_rc* {.
pure, size: sizeof(cint)
.} = enum FORMAT_ERROR = - 8, SIGNATURE_ERROR = - 7, CHALLENGE_ERROR = - 6, ORIGIN_ERROR = - 5, CRYPTO_ERROR = - 4, BASE64_ERROR = - 3, JSON_ERROR = - 2, MEMORY_ERROR = - 1, OK = 0
  Source Edit
U2FServerError* = object of Exception
  Source Edit
KeyHandle* = string
  Source Edit
PublicKey* = string
  Source Edit
U2FLoginData* = tuple[key_handle: KeyHandle, public_key: PublicKey]
  Source Edit

Consts

lib_fn* = "libu2f-server.so.0"
  Source Edit

Procs

proc u2fs_global_done*() {.
cdecl, importc: "u2fs_global_done", dynlib: lib_fn
.}
  Source Edit
proc u2fs_strerror_name*(err: cint): cstring {.
cdecl, importc: "u2fs_strerror_name", dynlib: lib_fn
.}
  Source Edit
proc u2fs_set_origin*(ctx: U2FServerCtx; origin: cstring): u2fs_rc {.
cdecl, importc: "u2fs_set_origin", dynlib: lib_fn
.}
  Source Edit
proc u2fs_set_appid*(ctx: U2FServerCtx; appid: cstring): u2fs_rc {.
cdecl, importc: "u2fs_set_appid", dynlib: lib_fn
.}
  Source Edit
proc u2fs_set_challenge*(ctx: U2FServerCtx; challenge: cstring): u2fs_rc {.
cdecl, importc: "u2fs_set_challenge", dynlib: lib_fn
.}
  Source Edit
proc u2fs_set_keyHandle*(ctx: U2FServerCtx; keyHandle: cstring): u2fs_rc {.
cdecl, importc: "u2fs_set_keyHandle", dynlib: lib_fn
.}
  Source Edit
proc u2fs_set_publicKey*(ctx: U2FServerCtx; publicKey: ptr cuchar): u2fs_rc {.
cdecl, importc: "u2fs_set_publicKey", dynlib: lib_fn
.}
  Source Edit
proc u2fs_registration_challenge*(ctx: U2FServerCtx; output: ptr cstring): u2fs_rc {.
cdecl, importc: "u2fs_registration_challenge", dynlib: lib_fn
.}
  Source Edit
proc u2fs_registration_verify*(ctx: U2FServerCtx; response: cstring;
                              output: ptr RegistrationResponse): u2fs_rc {.
cdecl, importc: "u2fs_registration_verify", dynlib: lib_fn
.}
  Source Edit
proc u2fs_get_registration_keyHandle*(result: RegistrationResponse): cstring {.
cdecl, importc: "u2fs_get_registration_keyHandle", dynlib: lib_fn
.}
  Source Edit
proc u2fs_free_reg_res*(result: RegistrationResponse) {.
cdecl, importc: "u2fs_free_reg_res", dynlib: lib_fn
.}
  Source Edit
proc u2fs_authentication_challenge*(ctx: U2FServerCtx; output: ptr cstring): u2fs_rc {.
cdecl, importc: "u2fs_authentication_challenge", dynlib: lib_fn
.}
  Source Edit
proc u2fs_authentication_verify*(ctx: U2FServerCtx; response: cstring;
                                output: ptr AuthenticationResponse): u2fs_rc {.
cdecl, importc: "u2fs_authentication_verify", dynlib: lib_fn
.}
  Source Edit
proc u2fs_get_authentication_result*(result: AuthenticationResponse;
                                    verified: ptr u2fs_rc; counter: ptr uint32;
                                    user_presence: ptr uint8): u2fs_rc {.
cdecl, importc: "u2fs_get_authentication_result", dynlib: lib_fn
.}
  Source Edit
proc u2fs_free_auth_res*(result: AuthenticationResponse) {.
cdecl, importc: "u2fs_free_auth_res", dynlib: lib_fn
.}
  Source Edit
proc newU2FServerCtx*(appid, origin: string; debug = false): U2FServerCtx
Initialize U2F server context   Source Edit
proc registration_challenge*(ctx: U2FServerCtx): string
  Source Edit
proc verify_registration*(ctx: U2FServerCtx; challenge: string): U2FLoginData
Verify registration and return key handle and public key. Store them on the server and they will be needed to authenticate.   Source Edit
proc set_public_key*(ctx: U2FServerCtx; public_key: string)
Set public key   Source Edit
proc generate_authentication_challenge*(ctx: U2FServerCtx; key_handle: string): string
Generate authentication challenge   Source Edit
proc verify_authentication*(ctx: U2FServerCtx; auth_msg: string)
Verify authentication challenge   Source Edit
proc set_challenge*(ctx: U2FServerCtx; challenge: string)
Set challenge   Source Edit
proc set_key_handle*(ctx: U2FServerCtx; key_handle: string)
Set key handle   Source Edit
proc done*(ctx: U2FServerCtx)
U2F server context destructor   Source Edit