pk11hpke.h (1862B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #ifndef _PK11_HPKE_H_ 6 #define _PK11_HPKE_H_ 1 7 8 #include "blapit.h" 9 #include "seccomon.h" 10 11 #define CLEANUP \ 12 PORT_Assert(rv == SECSuccess); \ 13 cleanup 14 15 /* Error code must already be set. */ 16 #define CHECK_RV(rv) \ 17 if ((rv) != SECSuccess) { \ 18 goto cleanup; \ 19 } 20 21 /* Error code must already be set. */ 22 #define CHECK_FAIL(cond) \ 23 if ((cond)) { \ 24 rv = SECFailure; \ 25 goto cleanup; \ 26 } 27 28 #define CHECK_FAIL_ERR(cond, err) \ 29 if ((cond)) { \ 30 PORT_SetError((err)); \ 31 rv = SECFailure; \ 32 goto cleanup; \ 33 } 34 35 typedef enum { 36 HpkeModeBase = 0, 37 HpkeModePsk = 1, 38 } HpkeModeId; 39 40 /* https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hpke-08#section-7.1 */ 41 typedef enum { 42 HpkeDhKemX25519Sha256 = 0x20, 43 } HpkeKemId; 44 45 typedef enum { 46 HpkeKdfHkdfSha256 = 1, 47 HpkeKdfHkdfSha384 = 2, 48 HpkeKdfHkdfSha512 = 3, 49 } HpkeKdfId; 50 51 typedef enum { 52 HpkeAeadAes128Gcm = 1, 53 HpkeAeadAes256Gcm = 2, 54 HpkeAeadChaCha20Poly1305 = 3, 55 } HpkeAeadId; 56 57 typedef struct hpkeKemParamsStr { 58 HpkeKemId id; 59 unsigned int Nsk; 60 unsigned int Nsecret; 61 unsigned int Npk; 62 SECOidTag oidTag; 63 CK_MECHANISM_TYPE hashMech; 64 } hpkeKemParams; 65 66 typedef struct hpkeKdfParamsStr { 67 HpkeKdfId id; 68 unsigned int Nh; 69 CK_MECHANISM_TYPE mech; 70 } hpkeKdfParams; 71 72 typedef struct hpkeAeadParamsStr { 73 HpkeAeadId id; 74 unsigned int Nk; 75 unsigned int Nn; 76 unsigned int tagLen; 77 CK_MECHANISM_TYPE mech; 78 } hpkeAeadParams; 79 80 typedef struct HpkeContextStr HpkeContext; 81 82 #endif /* _PK11_HPKE_H_ */