1*de0e0e4dSAntonio Huete Jimenez /* $OpenBSD: ssl_sigalgs.h,v 1.26 2022/07/02 16:00:12 tb Exp $ */ 272c33676SMaxim Ag /* 372c33676SMaxim Ag * Copyright (c) 2018-2019 Bob Beck <beck@openbsd.org> 472c33676SMaxim Ag * 572c33676SMaxim Ag * Permission to use, copy, modify, and/or distribute this software for any 672c33676SMaxim Ag * purpose with or without fee is hereby granted, provided that the above 772c33676SMaxim Ag * copyright notice and this permission notice appear in all copies. 872c33676SMaxim Ag * 972c33676SMaxim Ag * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 1072c33676SMaxim Ag * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 1172c33676SMaxim Ag * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 1272c33676SMaxim Ag * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 1372c33676SMaxim Ag * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 1472c33676SMaxim Ag * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN 1572c33676SMaxim Ag * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 1672c33676SMaxim Ag */ 1772c33676SMaxim Ag 1872c33676SMaxim Ag #ifndef HEADER_SSL_SIGALGS_H 1972c33676SMaxim Ag #define HEADER_SSL_SIGALGS_H 2072c33676SMaxim Ag 2172c33676SMaxim Ag __BEGIN_HIDDEN_DECLS 2272c33676SMaxim Ag 2372c33676SMaxim Ag #define SIGALG_NONE 0x0000 2472c33676SMaxim Ag 2572c33676SMaxim Ag /* 2672c33676SMaxim Ag * RFC 8446 Section 4.2.3 2772c33676SMaxim Ag * RFC 5246 Section 7.4.1.4.1 2872c33676SMaxim Ag */ 2972c33676SMaxim Ag #define SIGALG_RSA_PKCS1_SHA224 0x0301 3072c33676SMaxim Ag #define SIGALG_RSA_PKCS1_SHA256 0x0401 3172c33676SMaxim Ag #define SIGALG_RSA_PKCS1_SHA384 0x0501 3272c33676SMaxim Ag #define SIGALG_RSA_PKCS1_SHA512 0x0601 3372c33676SMaxim Ag #define SIGALG_ECDSA_SECP224R1_SHA224 0x0303 3472c33676SMaxim Ag #define SIGALG_ECDSA_SECP256R1_SHA256 0x0403 3572c33676SMaxim Ag #define SIGALG_ECDSA_SECP384R1_SHA384 0x0503 3672c33676SMaxim Ag #define SIGALG_ECDSA_SECP521R1_SHA512 0x0603 3772c33676SMaxim Ag #define SIGALG_RSA_PSS_RSAE_SHA256 0x0804 3872c33676SMaxim Ag #define SIGALG_RSA_PSS_RSAE_SHA384 0x0805 3972c33676SMaxim Ag #define SIGALG_RSA_PSS_RSAE_SHA512 0x0806 4072c33676SMaxim Ag #define SIGALG_ED25519 0x0807 4172c33676SMaxim Ag #define SIGALG_ED448 0x0808 4272c33676SMaxim Ag #define SIGALG_RSA_PSS_PSS_SHA256 0x0809 4372c33676SMaxim Ag #define SIGALG_RSA_PSS_PSS_SHA384 0x080a 4472c33676SMaxim Ag #define SIGALG_RSA_PSS_PSS_SHA512 0x080b 4572c33676SMaxim Ag #define SIGALG_RSA_PKCS1_SHA1 0x0201 4672c33676SMaxim Ag #define SIGALG_ECDSA_SHA1 0x0203 4772c33676SMaxim Ag #define SIGALG_PRIVATE_START 0xFE00 4872c33676SMaxim Ag #define SIGALG_PRIVATE_END 0xFFFF 4972c33676SMaxim Ag 5072c33676SMaxim Ag /* 5172c33676SMaxim Ag * If Russia can elect the US President, surely 5272c33676SMaxim Ag * IANA could fix this problem. 5372c33676SMaxim Ag */ 5472c33676SMaxim Ag #define SIGALG_GOSTR12_512_STREEBOG_512 0xEFEF 5572c33676SMaxim Ag #define SIGALG_GOSTR12_256_STREEBOG_256 0xEEEE 5672c33676SMaxim Ag #define SIGALG_GOSTR01_GOST94 0xEDED 5772c33676SMaxim Ag 58*de0e0e4dSAntonio Huete Jimenez /* Legacy sigalg for < TLSv1.2 same value as BoringSSL uses. */ 5972c33676SMaxim Ag #define SIGALG_RSA_PKCS1_MD5_SHA1 0xFF01 6072c33676SMaxim Ag 6172c33676SMaxim Ag #define SIGALG_FLAG_RSA_PSS 0x00000001 6272c33676SMaxim Ag 6372c33676SMaxim Ag struct ssl_sigalg { 6472c33676SMaxim Ag uint16_t value; 6572c33676SMaxim Ag int key_type; 66*de0e0e4dSAntonio Huete Jimenez const EVP_MD *(*md)(void); 67*de0e0e4dSAntonio Huete Jimenez int security_level; 68*de0e0e4dSAntonio Huete Jimenez int group_nid; 6972c33676SMaxim Ag int flags; 7072c33676SMaxim Ag }; 7172c33676SMaxim Ag 72*de0e0e4dSAntonio Huete Jimenez int ssl_sigalgs_build(uint16_t tls_version, CBB *cbb, int security_level); 7372c33676SMaxim Ag const struct ssl_sigalg *ssl_sigalg_select(SSL *s, EVP_PKEY *pkey); 74*de0e0e4dSAntonio Huete Jimenez const struct ssl_sigalg *ssl_sigalg_for_peer(SSL *s, EVP_PKEY *pkey, 75*de0e0e4dSAntonio Huete Jimenez uint16_t sigalg_value); 7672c33676SMaxim Ag 7772c33676SMaxim Ag __END_HIDDEN_DECLS 7872c33676SMaxim Ag 7972c33676SMaxim Ag #endif 80