2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <string.h> /* for memcpy() */
11 #include <openssl/core_names.h>
12 #include <openssl/crypto.h>
20 static const KEM_MODE eckem_modename_id_map
[] = {
21 { KEM_MODE_DHKEM
, OSSL_KEM_PARAM_OPERATION_DHKEM
},
25 int ossl_eckem_modename2id(const char *name
)
30 return KEM_MODE_UNDEFINED
;
32 for (i
= 0; eckem_modename_id_map
[i
].mode
!= NULL
; ++i
) {
33 if (OPENSSL_strcasecmp(name
, eckem_modename_id_map
[i
].mode
) == 0)
34 return eckem_modename_id_map
[i
].id
;
36 return KEM_MODE_UNDEFINED
;
39 /* suiteid = concat("KEM", I2OSP(kem_id, 2)) */
40 void ossl_dhkem_getsuiteid(unsigned char suiteid
[5], uint16_t kemid
)
42 memcpy(suiteid
, "KEM", 3);
43 suiteid
[3] = kemid
>> 8;
44 suiteid
[4] = kemid
& 0xFF;