Path: blob/main/contrib/bearssl/src/hash/dig_oid.c
39507 views
/*1* Copyright (c) 2016 Thomas Pornin <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining4* a copy of this software and associated documentation files (the5* "Software"), to deal in the Software without restriction, including6* without limitation the rights to use, copy, modify, merge, publish,7* distribute, sublicense, and/or sell copies of the Software, and to8* permit persons to whom the Software is furnished to do so, subject to9* the following conditions:10*11* The above copyright notice and this permission notice shall be12* included in all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,15* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND17* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS18* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN19* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN20* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*/2324#include "inner.h"2526/*27* This file contains the encoded OID for the standard hash functions.28* Such OID appear in, for instance, the PKCS#1 v1.5 padding for RSA29* signatures.30*/3132static const unsigned char md5_OID[] = {330x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x0534};3536static const unsigned char sha1_OID[] = {370x2B, 0x0E, 0x03, 0x02, 0x1A38};3940static const unsigned char sha224_OID[] = {410x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x0442};4344static const unsigned char sha256_OID[] = {450x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x0146};4748static const unsigned char sha384_OID[] = {490x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x0250};5152static const unsigned char sha512_OID[] = {530x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x0354};5556/* see inner.h */57const unsigned char *58br_digest_OID(int digest_id, size_t *len)59{60switch (digest_id) {61case br_md5_ID:62*len = sizeof md5_OID;63return md5_OID;64case br_sha1_ID:65*len = sizeof sha1_OID;66return sha1_OID;67case br_sha224_ID:68*len = sizeof sha224_OID;69return sha224_OID;70case br_sha256_ID:71*len = sizeof sha256_OID;72return sha256_OID;73case br_sha384_ID:74*len = sizeof sha384_OID;75return sha384_OID;76case br_sha512_ID:77*len = sizeof sha512_OID;78return sha512_OID;79default:80*len = 0;81return NULL;82}83}848586