|
| 1 | +/* |
| 2 | + * This file is part of the Pico FIDO distribution (https://github.com/polhenarejos/pico-fido). |
| 3 | + * Copyright (c) 2022 Pol Henarejos. |
| 4 | + * |
| 5 | + * This program is free software: you can redistribute it and/or modify |
| 6 | + * it under the terms of the GNU Affero General Public License as published by |
| 7 | + * the Free Software Foundation, version 3. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, but |
| 10 | + * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | + * Affero General Public License for more details. |
| 13 | + * |
| 14 | + * You should have received a copy of the GNU Affero General Public License |
| 15 | + * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | + */ |
| 17 | + |
| 18 | +#ifndef _VAULT_H_ |
| 19 | +#define _VAULT_H_ |
| 20 | + |
| 21 | +#include <stdbool.h> |
| 22 | +#include <stddef.h> |
| 23 | +#include <stdint.h> |
| 24 | +#include "ctap2_cbor.h" |
| 25 | +#include "credential.h" |
| 26 | +#include "serial.h" |
| 27 | +#include "fs/vault_container.h" |
| 28 | + |
| 29 | +#define VAULT_X448_BYTES PICOKEYS_VAULT_X448_BYTES |
| 30 | +#define VAULT_APP_ID 0u |
| 31 | +#define VAULT_CREDENTIAL_METADATA_MAX 512 |
| 32 | +#define VAULT_KEY_BYTES PICOKEYS_VAULT_KEY_SIZE |
| 33 | +#define VAULT_ID_BYTES PICOKEYS_VAULT_KEY_SIZE |
| 34 | +#define VAULT_ENROLL_CHALLENGE_BYTES PICOKEYS_VAULT_ENROLL_CHALLENGE_BYTES |
| 35 | +#define VAULT_ENROLL_CERT_MAX PICOKEYS_VAULT_ENROLL_CERT_MAX |
| 36 | +#define VAULT_ENROLL_MIN_PACKET_LEN PICOKEYS_VAULT_ENROLL_MIN_PACKET_LEN |
| 37 | +#define VAULT_LABEL_MAX 64 |
| 38 | +#define VAULT_ENROLL_PLAIN_MAX PICOKEYS_VAULT_ENROLL_PLAIN_MAX |
| 39 | +#define VAULT_STORE_LEN PICOKEYS_VAULT_RECORD_SIZE |
| 40 | +#define VAULT_BLOB_SERIAL_MAX 16 |
| 41 | +#define VAULT_BLOB_SERIAL_LEN_OFFSET (4 + VAULT_ID_BYTES + VAULT_ID_BYTES) |
| 42 | +#define VAULT_BLOB_SERIAL_OFFSET (VAULT_BLOB_SERIAL_LEN_OFFSET + 1) |
| 43 | +#define VAULT_BLOB_ALGORITHM_OFFSET (VAULT_BLOB_SERIAL_OFFSET + VAULT_BLOB_SERIAL_MAX) |
| 44 | +#define VAULT_BLOB_HEADER_LEN (VAULT_BLOB_ALGORITHM_OFFSET + 1) |
| 45 | +#define VAULT_BLOB_NONCE_BYTES PICOKEYS_VAULT_BLOB_NONCE_SIZE |
| 46 | +#define VAULT_PLAIN_MAX (MAX_CRED_ID_LENGTH + VAULT_CREDENTIAL_METADATA_MAX + 256) |
| 47 | +#define VAULT_BLOB_MAX (VAULT_BLOB_HEADER_LEN + 24 + VAULT_PLAIN_MAX + 32) |
| 48 | +extern int vault_load_key(uint8_t key[VAULT_KEY_BYTES]); |
| 49 | +extern int vault_enrollment_finish(const uint8_t *packet, size_t packet_len); |
| 50 | +extern int vault_export_blob(const uint8_t *requested_id, size_t requested_id_len, uint8_t algorithm, uint8_t *blob, size_t blob_capacity, size_t *blob_len, uint8_t *metadata, size_t metadata_capacity, size_t *metadata_len); |
| 51 | +extern int vault_import_blob(const uint8_t *blob, size_t blob_len); |
| 52 | +extern int vault_encode_credential_metadata(const Credential *credential, const uint8_t rp_id_hash[RP_ID_HASH_LEN], uint8_t *buffer, size_t buffer_len, size_t *metadata_len); |
| 53 | +extern CborError vault_vendor_command(uint64_t vendorCmd, CborByteString vendorParam, CborByteString pinUvAuthParam, uint64_t pinUvAuthProtocol, const uint8_t *raw_vendor_params, size_t raw_vendor_params_len, uint64_t vault_algorithm, bool vault_algorithm_present, CborEncoder encoder, size_t *resp_size, bool *response_handled, int *ctap_error); |
| 54 | + |
| 55 | +#endif |
0 commit comments