Create a new token if the secret key is well-formed.
(secret_key: bytes, identifier: bytes)
| 209 | |
| 210 | |
| 211 | def new_token(secret_key: bytes, identifier: bytes) -> bytes: |
| 212 | """Create a new token if the secret key is well-formed.""" |
| 213 | sk = _encode_bytes(secret_key) |
| 214 | id = _encode_bytes(identifier) |
| 215 | token = FfiByteBuffer() |
| 216 | err = FfiError() |
| 217 | |
| 218 | lib_fn = _get_func("oberon_new_token") |
| 219 | result = lib_fn(sk, id, byref(token), byref(err)) |
| 220 | if result == 0: |
| 221 | out = _decode_bytes(token) |
| 222 | #_free_buffer(token) |
| 223 | return out |
| 224 | else: |
| 225 | message = string_at(err.message) |
| 226 | #_free_string(err) |
| 227 | raise Exception(message) |
| 228 | |
| 229 | |
| 230 | def verify_token(token: bytes, public_key: bytes, identifier: bytes) -> bool: |
no test coverage detected