Path: blob/main/crypto/openssl/providers/common/der/der_ec_sig.c
48383 views
/*1* Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.2*3* Licensed under the Apache License 2.0 (the "License"). You may not use4* this file except in compliance with the License. You can obtain a copy5* in the file LICENSE in the source distribution or at6* https://www.openssl.org/source/license.html7*/89#include <openssl/obj_mac.h>10#include "internal/packet.h"11#include "prov/der_ec.h"1213/* Aliases so we can have a uniform MD_CASE */14#define ossl_der_oid_id_ecdsa_with_sha1 ossl_der_oid_ecdsa_with_SHA115#define ossl_der_oid_id_ecdsa_with_sha224 ossl_der_oid_ecdsa_with_SHA22416#define ossl_der_oid_id_ecdsa_with_sha256 ossl_der_oid_ecdsa_with_SHA25617#define ossl_der_oid_id_ecdsa_with_sha384 ossl_der_oid_ecdsa_with_SHA38418#define ossl_der_oid_id_ecdsa_with_sha512 ossl_der_oid_ecdsa_with_SHA5121920#define MD_CASE(name) \21case NID_##name: \22precompiled = ossl_der_oid_id_ecdsa_with_##name; \23precompiled_sz = sizeof(ossl_der_oid_id_ecdsa_with_##name); \24break;2526int ossl_DER_w_algorithmIdentifier_ECDSA_with_MD(WPACKET *pkt, int cont,27EC_KEY *ec, int mdnid)28{29const unsigned char *precompiled = NULL;30size_t precompiled_sz = 0;3132switch (mdnid) {33MD_CASE(sha1);34MD_CASE(sha224);35MD_CASE(sha256);36MD_CASE(sha384);37MD_CASE(sha512);38MD_CASE(sha3_224);39MD_CASE(sha3_256);40MD_CASE(sha3_384);41MD_CASE(sha3_512);42default:43return 0;44}4546return ossl_DER_w_begin_sequence(pkt, cont)47/* No parameters (yet?) */48&& ossl_DER_w_precompiled(pkt, -1, precompiled, precompiled_sz)49&& ossl_DER_w_end_sequence(pkt, cont);50}515253