2 * Copyright 2020 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
12 #include <openssl/objects.h>
13 #include "crypto/dsa.h"
15 #define ASN1_SEQUENCE 0x30
19 * id-dsa-with-sha1 OBJECT IDENTIFIER ::= {
20 * iso(1) member-body(2) us(840) x9-57(10040) x9cm(4) 3
23 #define ENCODE_ALGORITHMIDENTIFIER_RFC3279(name, n) \
24 static const unsigned char algorithmidentifier_##name##_der[] = { \
25 ASN1_SEQUENCE, 0x09, \
26 ASN1_OID, 0x07, 1 * 40 + 2, 134, 72, 206, 56, 4, n \
29 ENCODE_ALGORITHMIDENTIFIER_RFC3279(sha1, 3);
32 * dsaWithSHAx OIDs are of the form: (sigAlgs |n|)
33 * where sigAlgs OBJECT IDENTIFIER ::= { 2 16 840 1 101 3 4 3 }
35 #define ENCODE_ALGORITHMIDENTIFIER_SIGALGS(name, n) \
36 static const unsigned char algorithmidentifier_##name##_der[] = { \
37 ASN1_SEQUENCE, 0x0b, \
38 ASN1_OID, 0x09, 2 * 40 + 16, 0x86, 0x48, 1, 101, 3, 4, 3, n \
41 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha224, 1);
42 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha256, 2);
43 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha384, 3);
44 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha512, 4);
45 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha3_224, 5);
46 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha3_256, 6);
47 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha3_384, 7);
48 ENCODE_ALGORITHMIDENTIFIER_SIGALGS(sha3_512, 8);
50 #define MD_CASE(name) \
52 *len = sizeof(algorithmidentifier_##name##_der); \
53 return algorithmidentifier_##name##_der
55 const unsigned char *dsa_algorithmidentifier_encoding(int md_nid, size_t *len)