Path: blob/main/crypto/openssl/include/internal/der.h
103954 views
/*1* Copyright 2020-2022 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#ifndef OSSL_INTERNAL_DER_H10#define OSSL_INTERNAL_DER_H11#pragma once1213#include <openssl/bn.h>14#include "internal/packet.h"1516/*17* NOTE: X.690 numbers the identifier octet bits 1 to 8.18* We use the same numbering in comments here.19*/2021/* Well known primitive tags */2223/*24* DER UNIVERSAL tags, occupying bits 1-5 in the DER identifier byte25* These are only valid for the UNIVERSAL class. With the other classes,26* these bits have a different meaning.27*/28#define DER_P_EOC 0 /* BER End Of Contents tag */29#define DER_P_BOOLEAN 130#define DER_P_INTEGER 231#define DER_P_BIT_STRING 332#define DER_P_OCTET_STRING 433#define DER_P_NULL 534#define DER_P_OBJECT 635#define DER_P_OBJECT_DESCRIPTOR 736#define DER_P_EXTERNAL 837#define DER_P_REAL 938#define DER_P_ENUMERATED 1039#define DER_P_UTF8STRING 1240#define DER_P_SEQUENCE 1641#define DER_P_SET 1742#define DER_P_NUMERICSTRING 1843#define DER_P_PRINTABLESTRING 1944#define DER_P_T61STRING 2045#define DER_P_VIDEOTEXSTRING 2146#define DER_P_IA5STRING 2247#define DER_P_UTCTIME 2348#define DER_P_GENERALIZEDTIME 2449#define DER_P_GRAPHICSTRING 2550#define DER_P_ISO64STRING 2651#define DER_P_GENERALSTRING 2752#define DER_P_UNIVERSALSTRING 2853#define DER_P_BMPSTRING 305455/* DER Flags, occupying bit 6 in the DER identifier byte */56#define DER_F_PRIMITIVE 0x0057#define DER_F_CONSTRUCTED 0x205859/* DER classes tags, occupying bits 7-8 in the DER identifier byte */60#define DER_C_UNIVERSAL 0x0061#define DER_C_APPLICATION 0x4062#define DER_C_CONTEXT 0x8063#define DER_C_PRIVATE 0xC06465/*66* Run-time constructors.67*68* They all construct DER backwards, so care should be taken to use them69* that way.70*/7172/* This can be used for all items that don't have a context */73#define DER_NO_CONTEXT -17475int ossl_DER_w_precompiled(WPACKET *pkt, int tag,76const unsigned char *precompiled,77size_t precompiled_n);7879int ossl_DER_w_boolean(WPACKET *pkt, int tag, int b);80int ossl_DER_w_uint32(WPACKET *pkt, int tag, uint32_t v);81int ossl_DER_w_bn(WPACKET *pkt, int tag, const BIGNUM *v);82int ossl_DER_w_null(WPACKET *pkt, int tag);83int ossl_DER_w_octet_string(WPACKET *pkt, int tag,84const unsigned char *data, size_t data_n);85int ossl_DER_w_octet_string_uint32(WPACKET *pkt, int tag, uint32_t value);8687/*88* All constructors for constructed elements have a begin and a end function89*/90int ossl_DER_w_begin_sequence(WPACKET *pkt, int tag);91int ossl_DER_w_end_sequence(WPACKET *pkt, int tag);9293#endif949596