FreeRDP
asn1.c File Reference
#include <winpr/config.h>
#include <winpr/asn1.h>
#include <winpr/wlog.h>
#include <winpr/crt.h>
#include "../../log.h"

Macros

#define TAG   WINPR_TAG("asn1")
 
#define MAX_STATIC_ITEMS   50
 
#define WINPR_ASSERT_VALID_TAG(t)   WINPR_ASSERT(t < 64)
 

Enumerations

enum  ContainerType {
  ASN1_CONTAINER_SEQ , ASN1_CONTAINER_SET , ASN1_CONTAINER_APP , ASN1_CONTAINER_CONTEXT_ONLY ,
  ASN1_CONTAINER_OCTETSTRING
}
 type of encoder container More...
 

Functions

void WinPrAsn1FreeOID (WinPrAsn1_OID *poid)
 
void WinPrAsn1FreeOctetString (WinPrAsn1_OctetString *octets)
 
WinPrAsn1Encoder * WinPrAsn1Encoder_New (WinPrAsn1EncodingRule encoding)
 
void WinPrAsn1Encoder_Reset (WinPrAsn1Encoder *enc)
 
void WinPrAsn1Encoder_Free (WinPrAsn1Encoder **penc)
 
static Asn1Chunk * asn1enc_get_free_chunk (WinPrAsn1Encoder *enc, size_t chunkSz, BOOL commit, size_t *id)
 
static WinPrAsn1EncContainer * asn1enc_get_free_container (WinPrAsn1Encoder *enc, size_t *id)
 
static size_t lenBytes (size_t len)
 
static void asn1WriteLen (wStream *s, size_t len)
 
static WinPrAsn1EncContainer * getAsn1Container (WinPrAsn1Encoder *enc, ContainerType ctype, WinPrAsn1_tag tag, BOOL contextual, size_t maxLen)
 
BOOL WinPrAsn1EncAppContainer (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId)
 
BOOL WinPrAsn1EncSeqContainer (WinPrAsn1Encoder *enc)
 
BOOL WinPrAsn1EncSetContainer (WinPrAsn1Encoder *enc)
 
BOOL WinPrAsn1EncContextualSeqContainer (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId)
 
BOOL WinPrAsn1EncContextualSetContainer (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId)
 
BOOL WinPrAsn1EncContextualContainer (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId)
 
BOOL WinPrAsn1EncOctetStringContainer (WinPrAsn1Encoder *enc)
 
BOOL WinPrAsn1EncContextualOctetStringContainer (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId)
 
size_t WinPrAsn1EncEndContainer (WinPrAsn1Encoder *enc)
 
static BOOL asn1_getWriteStream (WinPrAsn1Encoder *enc, size_t len, wStream *s)
 
size_t WinPrAsn1EncRawContent (WinPrAsn1Encoder *enc, const WinPrAsn1_MemoryChunk *c)
 
size_t WinPrAsn1EncContextualRawContent (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, const WinPrAsn1_MemoryChunk *c)
 
static size_t asn1IntegerLen (WinPrAsn1_INTEGER value)
 
static size_t WinPrAsn1EncIntegerLike (WinPrAsn1Encoder *enc, WinPrAsn1_tag b, WinPrAsn1_INTEGER value)
 
size_t WinPrAsn1EncInteger (WinPrAsn1Encoder *enc, WinPrAsn1_INTEGER value)
 
size_t WinPrAsn1EncEnumerated (WinPrAsn1Encoder *enc, WinPrAsn1_ENUMERATED value)
 
static size_t WinPrAsn1EncContextualIntegerLike (WinPrAsn1Encoder *enc, WinPrAsn1_tag tag, WinPrAsn1_tagId tagId, WinPrAsn1_INTEGER value)
 
size_t WinPrAsn1EncContextualInteger (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, WinPrAsn1_INTEGER value)
 
size_t WinPrAsn1EncContextualEnumerated (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, WinPrAsn1_ENUMERATED value)
 
size_t WinPrAsn1EncBoolean (WinPrAsn1Encoder *enc, WinPrAsn1_BOOL b)
 
size_t WinPrAsn1EncContextualBoolean (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, WinPrAsn1_BOOL b)
 
static size_t WinPrAsn1EncMemoryChunk (WinPrAsn1Encoder *enc, BYTE wireType, const WinPrAsn1_MemoryChunk *mchunk)
 
size_t WinPrAsn1EncOID (WinPrAsn1Encoder *enc, const WinPrAsn1_OID *oid)
 
size_t WinPrAsn1EncOctetString (WinPrAsn1Encoder *enc, const WinPrAsn1_OctetString *octets)
 
size_t WinPrAsn1EncIA5String (WinPrAsn1Encoder *enc, WinPrAsn1_IA5STRING ia5)
 
size_t WinPrAsn1EncGeneralString (WinPrAsn1Encoder *enc, WinPrAsn1_STRING str)
 
static size_t WinPrAsn1EncContextualMemoryChunk (WinPrAsn1Encoder *enc, BYTE wireType, WinPrAsn1_tagId tagId, const WinPrAsn1_MemoryChunk *mchunk)
 
size_t WinPrAsn1EncContextualOID (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, const WinPrAsn1_OID *oid)
 
size_t WinPrAsn1EncContextualOctetString (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, const WinPrAsn1_OctetString *octets)
 
size_t WinPrAsn1EncContextualIA5String (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, WinPrAsn1_IA5STRING ia5)
 
static void write2digit (wStream *s, UINT8 v)
 
size_t WinPrAsn1EncUtcTime (WinPrAsn1Encoder *enc, const WinPrAsn1_UTCTIME *utc)
 
size_t WinPrAsn1EncContextualUtcTime (WinPrAsn1Encoder *enc, WinPrAsn1_tagId tagId, const WinPrAsn1_UTCTIME *utc)
 
BOOL WinPrAsn1EncStreamSize (WinPrAsn1Encoder *enc, size_t *s)
 
BOOL WinPrAsn1EncToStream (WinPrAsn1Encoder *enc, wStream *s)
 
void WinPrAsn1Decoder_Init (WinPrAsn1Decoder *decoder, WinPrAsn1EncodingRule encoding, wStream *source)
 
void WinPrAsn1Decoder_InitMem (WinPrAsn1Decoder *decoder, WinPrAsn1EncodingRule encoding, const BYTE *source, size_t len)
 
BOOL WinPrAsn1DecPeekTag (WinPrAsn1Decoder *dec, WinPrAsn1_tag *tag)
 
static size_t readLen (wStream *s, size_t *len, BOOL derCheck)
 
static size_t readTagAndLen (WinPrAsn1Decoder *dec, wStream *s, WinPrAsn1_tag *tag, size_t *len)
 
size_t WinPrAsn1DecReadTagAndLen (WinPrAsn1Decoder *dec, WinPrAsn1_tag *tag, size_t *len)
 
size_t WinPrAsn1DecPeekTagAndLen (WinPrAsn1Decoder *dec, WinPrAsn1_tag *tag, size_t *len)
 
size_t WinPrAsn1DecReadTagLenValue (WinPrAsn1Decoder *dec, WinPrAsn1_tag *tag, size_t *len, WinPrAsn1Decoder *value)
 
size_t WinPrAsn1DecReadBoolean (WinPrAsn1Decoder *dec, WinPrAsn1_BOOL *target)
 
static size_t WinPrAsn1DecReadIntegerLike (WinPrAsn1Decoder *dec, WinPrAsn1_tag expectedTag, WinPrAsn1_INTEGER *target)
 
size_t WinPrAsn1DecReadInteger (WinPrAsn1Decoder *dec, WinPrAsn1_INTEGER *target)
 
size_t WinPrAsn1DecReadEnumerated (WinPrAsn1Decoder *dec, WinPrAsn1_ENUMERATED *target)
 
static size_t WinPrAsn1DecReadMemoryChunkLike (WinPrAsn1Decoder *dec, WinPrAsn1_tag expectedTag, WinPrAsn1_MemoryChunk *target, BOOL allocate)
 
size_t WinPrAsn1DecReadOID (WinPrAsn1Decoder *dec, WinPrAsn1_OID *target, BOOL allocate)
 
size_t WinPrAsn1DecReadOctetString (WinPrAsn1Decoder *dec, WinPrAsn1_OctetString *target, BOOL allocate)
 
size_t WinPrAsn1DecReadIA5String (WinPrAsn1Decoder *dec, WinPrAsn1_IA5STRING *target)
 
size_t WinPrAsn1DecReadGeneralString (WinPrAsn1Decoder *dec, WinPrAsn1_STRING *target)
 
static int read2digits (wStream *s)
 
size_t WinPrAsn1DecReadUtcTime (WinPrAsn1Decoder *dec, WinPrAsn1_UTCTIME *target)
 
size_t WinPrAsn1DecReadNull (WinPrAsn1Decoder *dec)
 
static size_t readConstructed (WinPrAsn1Decoder *dec, wStream *s, WinPrAsn1_tag *tag, WinPrAsn1Decoder *target)
 
size_t WinPrAsn1DecReadApp (WinPrAsn1Decoder *dec, WinPrAsn1_tagId *tagId, WinPrAsn1Decoder *target)
 
size_t WinPrAsn1DecReadSequence (WinPrAsn1Decoder *dec, WinPrAsn1Decoder *target)
 
size_t WinPrAsn1DecReadSet (WinPrAsn1Decoder *dec, WinPrAsn1Decoder *target)
 
size_t readContextualTag (WinPrAsn1Decoder *dec, wStream *s, WinPrAsn1_tagId *tagId, WinPrAsn1Decoder *ctxtDec)
 
size_t WinPrAsn1DecReadContextualTag (WinPrAsn1Decoder *dec, WinPrAsn1_tagId *tagId, WinPrAsn1Decoder *ctxtDec)
 
size_t WinPrAsn1DecPeekContextualTag (WinPrAsn1Decoder *dec, WinPrAsn1_tagId *tagId, WinPrAsn1Decoder *ctxtDec)
 
static size_t readContextualHeader (WinPrAsn1Decoder *dec, WinPrAsn1_tagId tagId, BOOL *error, WinPrAsn1Decoder *content)
 
size_t WinPrAsn1DecReadContextualBool (WinPrAsn1Decoder *dec, WinPrAsn1_tagId tagId, BOOL *error, WinPrAsn1_BOOL *target)
 
size_t WinPrAsn1DecReadContextualInteger (WinPrAsn1Decoder *dec, WinPrAsn1_tagId tagId, BOOL *error, WinPrAsn1_INTEGER *target)
 
size_t WinPrAsn1DecReadContextualOID (WinPrAsn1Decoder *dec, WinPrAsn1_tagId tagId, BOOL *error, WinPrAsn1_OID *target, BOOL allocate)
 
size_t WinPrAsn1DecReadContextualOctetString (WinPrAsn1Decoder *dec, WinPrAsn1_tagId tagId, BOOL *error, WinPrAsn1_OctetString *target, BOOL allocate)
 
size_t WinPrAsn1DecReadContextualSequence (WinPrAsn1Decoder *dec, WinPrAsn1_tagId tagId, BOOL *error, WinPrAsn1Decoder *target)
 
wStream WinPrAsn1DecGetStream (WinPrAsn1Decoder *dec)
 

Macro Definition Documentation

◆ MAX_STATIC_ITEMS

#define MAX_STATIC_ITEMS   50

◆ TAG

#define TAG   WINPR_TAG("asn1")

WinPR: Windows Portable Runtime ASN1 routines

Copyright 2022 David Fort conta.nosp@m.ct@h.nosp@m.arden.nosp@m.ing-.nosp@m.consu.nosp@m.ltin.nosp@m.g.com

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ WINPR_ASSERT_VALID_TAG

#define WINPR_ASSERT_VALID_TAG (   t)    WINPR_ASSERT(t < 64)

Enumeration Type Documentation

◆ ContainerType

type of encoder container

Enumerator
ASN1_CONTAINER_SEQ 
ASN1_CONTAINER_SET 
ASN1_CONTAINER_APP 
ASN1_CONTAINER_CONTEXT_ONLY 
ASN1_CONTAINER_OCTETSTRING 

Function Documentation

◆ asn1_getWriteStream()

static BOOL asn1_getWriteStream ( WinPrAsn1Encoder *  enc,
size_t  len,
wStream s 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ asn1enc_get_free_chunk()

static Asn1Chunk* asn1enc_get_free_chunk ( WinPrAsn1Encoder *  enc,
size_t  chunkSz,
BOOL  commit,
size_t *  id 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ asn1enc_get_free_container()

static WinPrAsn1EncContainer* asn1enc_get_free_container ( WinPrAsn1Encoder *  enc,
size_t *  id 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ asn1IntegerLen()

static size_t asn1IntegerLen ( WinPrAsn1_INTEGER  value)
static
Here is the caller graph for this function:

◆ asn1WriteLen()

static void asn1WriteLen ( wStream s,
size_t  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAsn1Container()

static WinPrAsn1EncContainer* getAsn1Container ( WinPrAsn1Encoder *  enc,
ContainerType  ctype,
WinPrAsn1_tag  tag,
BOOL  contextual,
size_t  maxLen 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ lenBytes()

static size_t lenBytes ( size_t  len)
static
Here is the caller graph for this function:

◆ read2digits()

static int read2digits ( wStream s)
static
Here is the caller graph for this function:

◆ readConstructed()

static size_t readConstructed ( WinPrAsn1Decoder dec,
wStream s,
WinPrAsn1_tag tag,
WinPrAsn1Decoder target 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readContextualHeader()

static size_t readContextualHeader ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId  tagId,
BOOL *  error,
WinPrAsn1Decoder content 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readContextualTag()

size_t readContextualTag ( WinPrAsn1Decoder dec,
wStream s,
WinPrAsn1_tagId tagId,
WinPrAsn1Decoder ctxtDec 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ readLen()

static size_t readLen ( wStream s,
size_t *  len,
BOOL  derCheck 
)
static
Here is the caller graph for this function:

◆ readTagAndLen()

static size_t readTagAndLen ( WinPrAsn1Decoder dec,
wStream s,
WinPrAsn1_tag tag,
size_t *  len 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecGetStream()

wStream WinPrAsn1DecGetStream ( WinPrAsn1Decoder dec)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1Decoder_Init()

void WinPrAsn1Decoder_Init ( WinPrAsn1Decoder decoder,
WinPrAsn1EncodingRule  encoding,
wStream source 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1Decoder_InitMem()

void WinPrAsn1Decoder_InitMem ( WinPrAsn1Decoder decoder,
WinPrAsn1EncodingRule  encoding,
const BYTE source,
size_t  len 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecPeekContextualTag()

size_t WinPrAsn1DecPeekContextualTag ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId tagId,
WinPrAsn1Decoder ctxtDec 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecPeekTag()

BOOL WinPrAsn1DecPeekTag ( WinPrAsn1Decoder dec,
WinPrAsn1_tag tag 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecPeekTagAndLen()

size_t WinPrAsn1DecPeekTagAndLen ( WinPrAsn1Decoder dec,
WinPrAsn1_tag tag,
size_t *  len 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadApp()

size_t WinPrAsn1DecReadApp ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId tagId,
WinPrAsn1Decoder target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadBoolean()

size_t WinPrAsn1DecReadBoolean ( WinPrAsn1Decoder dec,
WinPrAsn1_BOOL target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadContextualBool()

size_t WinPrAsn1DecReadContextualBool ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId  tagId,
BOOL *  error,
WinPrAsn1_BOOL target 
)
Here is the call graph for this function:

◆ WinPrAsn1DecReadContextualInteger()

size_t WinPrAsn1DecReadContextualInteger ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId  tagId,
BOOL *  error,
WinPrAsn1_INTEGER target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadContextualOctetString()

size_t WinPrAsn1DecReadContextualOctetString ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId  tagId,
BOOL *  error,
WinPrAsn1_OctetString target,
BOOL  allocate 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadContextualOID()

size_t WinPrAsn1DecReadContextualOID ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId  tagId,
BOOL *  error,
WinPrAsn1_OID target,
BOOL  allocate 
)
Here is the call graph for this function:

◆ WinPrAsn1DecReadContextualSequence()

size_t WinPrAsn1DecReadContextualSequence ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId  tagId,
BOOL *  error,
WinPrAsn1Decoder target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadContextualTag()

size_t WinPrAsn1DecReadContextualTag ( WinPrAsn1Decoder dec,
WinPrAsn1_tagId tagId,
WinPrAsn1Decoder ctxtDec 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadEnumerated()

size_t WinPrAsn1DecReadEnumerated ( WinPrAsn1Decoder dec,
WinPrAsn1_ENUMERATED target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadGeneralString()

size_t WinPrAsn1DecReadGeneralString ( WinPrAsn1Decoder dec,
WinPrAsn1_STRING target 
)
Here is the call graph for this function:

◆ WinPrAsn1DecReadIA5String()

size_t WinPrAsn1DecReadIA5String ( WinPrAsn1Decoder dec,
WinPrAsn1_IA5STRING target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadInteger()

size_t WinPrAsn1DecReadInteger ( WinPrAsn1Decoder dec,
WinPrAsn1_INTEGER target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadIntegerLike()

static size_t WinPrAsn1DecReadIntegerLike ( WinPrAsn1Decoder dec,
WinPrAsn1_tag  expectedTag,
WinPrAsn1_INTEGER target 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadMemoryChunkLike()

static size_t WinPrAsn1DecReadMemoryChunkLike ( WinPrAsn1Decoder dec,
WinPrAsn1_tag  expectedTag,
WinPrAsn1_MemoryChunk target,
BOOL  allocate 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadNull()

size_t WinPrAsn1DecReadNull ( WinPrAsn1Decoder dec)
Here is the call graph for this function:

◆ WinPrAsn1DecReadOctetString()

size_t WinPrAsn1DecReadOctetString ( WinPrAsn1Decoder dec,
WinPrAsn1_OctetString target,
BOOL  allocate 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadOID()

size_t WinPrAsn1DecReadOID ( WinPrAsn1Decoder dec,
WinPrAsn1_OID target,
BOOL  allocate 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadSequence()

size_t WinPrAsn1DecReadSequence ( WinPrAsn1Decoder dec,
WinPrAsn1Decoder target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadSet()

size_t WinPrAsn1DecReadSet ( WinPrAsn1Decoder dec,
WinPrAsn1Decoder target 
)
Here is the call graph for this function:

◆ WinPrAsn1DecReadTagAndLen()

size_t WinPrAsn1DecReadTagAndLen ( WinPrAsn1Decoder dec,
WinPrAsn1_tag tag,
size_t *  len 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadTagLenValue()

size_t WinPrAsn1DecReadTagLenValue ( WinPrAsn1Decoder dec,
WinPrAsn1_tag tag,
size_t *  len,
WinPrAsn1Decoder value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1DecReadUtcTime()

size_t WinPrAsn1DecReadUtcTime ( WinPrAsn1Decoder dec,
WinPrAsn1_UTCTIME target 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncAppContainer()

BOOL WinPrAsn1EncAppContainer ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncBoolean()

size_t WinPrAsn1EncBoolean ( WinPrAsn1Encoder *  enc,
WinPrAsn1_BOOL  b 
)
Here is the call graph for this function:

◆ WinPrAsn1EncContextualBoolean()

size_t WinPrAsn1EncContextualBoolean ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
WinPrAsn1_BOOL  b 
)
Here is the call graph for this function:

◆ WinPrAsn1EncContextualContainer()

BOOL WinPrAsn1EncContextualContainer ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualEnumerated()

size_t WinPrAsn1EncContextualEnumerated ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
WinPrAsn1_ENUMERATED  value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualIA5String()

size_t WinPrAsn1EncContextualIA5String ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
WinPrAsn1_IA5STRING  ia5 
)
Here is the call graph for this function:

◆ WinPrAsn1EncContextualInteger()

size_t WinPrAsn1EncContextualInteger ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
WinPrAsn1_INTEGER  value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualIntegerLike()

static size_t WinPrAsn1EncContextualIntegerLike ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tag  tag,
WinPrAsn1_tagId  tagId,
WinPrAsn1_INTEGER  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualMemoryChunk()

static size_t WinPrAsn1EncContextualMemoryChunk ( WinPrAsn1Encoder *  enc,
BYTE  wireType,
WinPrAsn1_tagId  tagId,
const WinPrAsn1_MemoryChunk mchunk 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualOctetString()

size_t WinPrAsn1EncContextualOctetString ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
const WinPrAsn1_OctetString octets 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualOctetStringContainer()

BOOL WinPrAsn1EncContextualOctetStringContainer ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualOID()

size_t WinPrAsn1EncContextualOID ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
const WinPrAsn1_OID oid 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualRawContent()

size_t WinPrAsn1EncContextualRawContent ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
const WinPrAsn1_MemoryChunk c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualSeqContainer()

BOOL WinPrAsn1EncContextualSeqContainer ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncContextualSetContainer()

BOOL WinPrAsn1EncContextualSetContainer ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId 
)
Here is the call graph for this function:

◆ WinPrAsn1EncContextualUtcTime()

size_t WinPrAsn1EncContextualUtcTime ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tagId  tagId,
const WinPrAsn1_UTCTIME utc 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncEndContainer()

size_t WinPrAsn1EncEndContainer ( WinPrAsn1Encoder *  enc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncEnumerated()

size_t WinPrAsn1EncEnumerated ( WinPrAsn1Encoder *  enc,
WinPrAsn1_ENUMERATED  value 
)
Here is the call graph for this function:

◆ WinPrAsn1EncGeneralString()

size_t WinPrAsn1EncGeneralString ( WinPrAsn1Encoder *  enc,
WinPrAsn1_STRING  str 
)
Here is the call graph for this function:

◆ WinPrAsn1EncIA5String()

size_t WinPrAsn1EncIA5String ( WinPrAsn1Encoder *  enc,
WinPrAsn1_IA5STRING  ia5 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncInteger()

size_t WinPrAsn1EncInteger ( WinPrAsn1Encoder *  enc,
WinPrAsn1_INTEGER  value 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncIntegerLike()

static size_t WinPrAsn1EncIntegerLike ( WinPrAsn1Encoder *  enc,
WinPrAsn1_tag  b,
WinPrAsn1_INTEGER  value 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncMemoryChunk()

static size_t WinPrAsn1EncMemoryChunk ( WinPrAsn1Encoder *  enc,
BYTE  wireType,
const WinPrAsn1_MemoryChunk mchunk 
)
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncOctetString()

size_t WinPrAsn1EncOctetString ( WinPrAsn1Encoder *  enc,
const WinPrAsn1_OctetString octets 
)
Here is the call graph for this function:

◆ WinPrAsn1EncOctetStringContainer()

BOOL WinPrAsn1EncOctetStringContainer ( WinPrAsn1Encoder *  enc)
Here is the call graph for this function:

◆ WinPrAsn1Encoder_Free()

void WinPrAsn1Encoder_Free ( WinPrAsn1Encoder **  penc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1Encoder_New()

WinPrAsn1Encoder* WinPrAsn1Encoder_New ( WinPrAsn1EncodingRule  encoding)

The encoder is implemented with the goals to:

  • have an API which is convenient to use (avoid computing inner elements size)
  • hide the BER/DER encoding details
  • avoid multiple copies and memory moves when building the content

To achieve this, the encoder contains a big memory block (encoder->pool), and various chunks (encoder->chunks) pointing to that memory block. The idea is to reserve some space in the pool for the container headers when we start a new container element. For example when a sequence is started we reserve 6 bytes which is the maximum size: byte0 + length. Then fill the content of the sequence in further chunks. When a container is closed, we compute the inner size (by adding the size of inner chunks), we write the headers bytes, and we adjust the chunk size accordingly.

For example to encode: SEQ IASTRING(test1) INTEGER(200)

with this code:

WinPrAsn1EncSeqContainer(enc);
WinPrAsn1EncIA5String(enc, "test1");
WinPrAsn1EncInteger(enc, 200);

Memory pool and chunks would look like:

[ reserved for seq][string|5|"test1"][integer|0x81|200] (6 bytes) |--------------—||-------------------------------—| ^ ^ | | chunk0 chunk1

As we try to compact chunks as much as we can, we managed to encode the ia5string and the integer using the same chunk.

When the sequence is closed with:

WinPrAsn1EncEndContainer(enc);

The final pool and chunks will look like:

XXXXXX[seq headers][string|5|"test1"][integer|0x81|200]

  |-----------||----------------------------------|
  ^            ^
  |            |
chunk0       chunk1

The generated content can be retrieved using:

WinPrAsn1EncToStream(enc, targetStream);

It will sequentially write all the chunks in the given target stream.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1Encoder_Reset()

void WinPrAsn1Encoder_Reset ( WinPrAsn1Encoder *  enc)
Here is the caller graph for this function:

◆ WinPrAsn1EncOID()

size_t WinPrAsn1EncOID ( WinPrAsn1Encoder *  enc,
const WinPrAsn1_OID oid 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncRawContent()

size_t WinPrAsn1EncRawContent ( WinPrAsn1Encoder *  enc,
const WinPrAsn1_MemoryChunk c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncSeqContainer()

BOOL WinPrAsn1EncSeqContainer ( WinPrAsn1Encoder *  enc)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncSetContainer()

BOOL WinPrAsn1EncSetContainer ( WinPrAsn1Encoder *  enc)
Here is the call graph for this function:

◆ WinPrAsn1EncStreamSize()

BOOL WinPrAsn1EncStreamSize ( WinPrAsn1Encoder *  enc,
size_t *  s 
)
Here is the caller graph for this function:

◆ WinPrAsn1EncToStream()

BOOL WinPrAsn1EncToStream ( WinPrAsn1Encoder *  enc,
wStream s 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WinPrAsn1EncUtcTime()

size_t WinPrAsn1EncUtcTime ( WinPrAsn1Encoder *  enc,
const WinPrAsn1_UTCTIME utc 
)
Here is the call graph for this function:

◆ WinPrAsn1FreeOctetString()

void WinPrAsn1FreeOctetString ( WinPrAsn1_OctetString octets)
Here is the call graph for this function:

◆ WinPrAsn1FreeOID()

void WinPrAsn1FreeOID ( WinPrAsn1_OID poid)
Here is the caller graph for this function:

◆ write2digit()

static void write2digit ( wStream s,
UINT8  v 
)
static
Here is the call graph for this function:
Here is the caller graph for this function: