JunkBox_Lib  1.10.2
asn1_node.h File Reference
#include "buffer.h"
#include "asn1_tool.h"
Include dependency graph for asn1_node.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define JBXL_ASN1_ANCHOR   0xff
 ANCHOR. More...
 
#define JBXL_ASN1_PRIMITIVE   0x00
 PRIMITIVE. More...
 
#define JBXL_ASN1_CNSTRCTD   0x20
 CONSTRUCTED 構造化フラグ More...
 
#define JBXL_ASN1_UNIVERSAL   0x00
 UNIVERSAL. More...
 
#define JBXL_ASN1_APPLI   0x40
 APPLICATION. More...
 
#define JBXL_ASN1_CONTEXT   0x80
 CONTEXT-DEFINED. More...
 
#define JBXL_ASN1_PRIVATE   0xc0
 PRIVATE. More...
 
#define JBXL_ASN1_END   0x00
 DATA_END. More...
 
#define JBXL_ASN1_BOOL   0x01
 BOOLEAN. More...
 
#define JBXL_ASN1_INT   0x02
 INTEGER. More...
 
#define JBXL_ASN1_BIT   0x03
 BIT_STRING. More...
 
#define JBXL_ASN1_OCT   0x04
 OCTET_STRING. More...
 
#define JBXL_ASN1_NULL   0x05
 NULL. More...
 
#define JBXL_ASN1_OBJ   0x06
 OBJECT_IDENTIFIER. More...
 
#define JBXL_ASN1_DSC   0x07
 OBJECT_DESCRITOR. More...
 
#define JBXL_ASN1_EXT   0x08
 EXTERNAL. More...
 
#define JBXL_ASN1_REAL   0x09
 REAL. More...
 
#define JBXL_ASN1_ENU   0x0a
 ENUMERATED. More...
 
#define JBXL_ASN1_EMB   0x0b
 EMBEDDED_PDV. More...
 
#define JBXL_ASN1_UTF8   0x0c
 UTF8_STRING. More...
 
#define JBXL_ASN1_OID   0x0d
 RELATIVE-OID. More...
 
#define JBXL_ASN1_SEQ   0x10
 SEQUENCE. More...
 
#define JBXL_ASN1_SET   0x11
 SET. More...
 
#define JBXL_ASN1_NMSTR   0x12
 NUMERIC_STRING. More...
 
#define JBXL_ASN1_PRSTR   0x13
 PRINTABLE_STRING. More...
 
#define JBXL_ASN1_TLSTR   0x14
 TELETEX_STRING. More...
 
#define JBXL_ASN1_VDSTR   0x15
 VIDEOTEX_STRING. More...
 
#define JBXL_ASN1_IA5   0x16
 IA5_STRING. More...
 
#define JBXL_ASN1_UTC   0x17
 UTC_TIME. More...
 
#define JBXL_ASN1_GTM   0x18
 GENERALIZED_TIME. More...
 
#define JBXL_ASN1_GRSTR   0x19
 GRAPHIC_STRING. More...
 
#define JBXL_ASN1_VSSTR   0x1a
 VISIBLE_STRING. More...
 
#define JBXL_ASN1_GNSTR   0x1b
 GENERAL_STRING. More...
 
#define JBXL_ASN1_UNSTR   0x1c
 UNIVERSAL_STRING. More...
 
#define JBXL_ASN1_CHSTR   0x1d
 CHARACTER_STRING. More...
 
#define JBXL_ASN1_BMSTR   0x1e
 BMP_STRING. More...
 
#define JBXL_ASN1_SEQ_CNSTRCTD   0x30
 SEQUENCE + CONSTRUCTED (構造化フラグ) More...
 
#define JBXL_ASN1_SET_CNSTRCTD   0x31
 SET + CONSTRUCTED (構造化フラグ) More...
 

Functions

void asn1_print_id (FILE *fp, int id)
 
void asn1_id_type (int id, int *type, int *cnst, int *tag)
 
void asn1_print_tag_value (FILE *fp, int tag, Buffer buf)
 

Macro Definition Documentation

◆ JBXL_ASN1_ANCHOR

#define JBXL_ASN1_ANCHOR   0xff

Definition at line 11 of file asn1_node.h.

◆ JBXL_ASN1_APPLI

#define JBXL_ASN1_APPLI   0x40

Definition at line 17 of file asn1_node.h.

◆ JBXL_ASN1_BIT

#define JBXL_ASN1_BIT   0x03

Definition at line 24 of file asn1_node.h.

◆ JBXL_ASN1_BMSTR

#define JBXL_ASN1_BMSTR   0x1e

Definition at line 50 of file asn1_node.h.

◆ JBXL_ASN1_BOOL

#define JBXL_ASN1_BOOL   0x01

Definition at line 22 of file asn1_node.h.

◆ JBXL_ASN1_CHSTR

#define JBXL_ASN1_CHSTR   0x1d

Definition at line 49 of file asn1_node.h.

◆ JBXL_ASN1_CNSTRCTD

#define JBXL_ASN1_CNSTRCTD   0x20

Definition at line 14 of file asn1_node.h.

◆ JBXL_ASN1_CONTEXT

#define JBXL_ASN1_CONTEXT   0x80

Definition at line 18 of file asn1_node.h.

◆ JBXL_ASN1_DSC

#define JBXL_ASN1_DSC   0x07

Definition at line 28 of file asn1_node.h.

◆ JBXL_ASN1_EMB

#define JBXL_ASN1_EMB   0x0b

Definition at line 32 of file asn1_node.h.

◆ JBXL_ASN1_END

#define JBXL_ASN1_END   0x00

Definition at line 21 of file asn1_node.h.

◆ JBXL_ASN1_ENU

#define JBXL_ASN1_ENU   0x0a

Definition at line 31 of file asn1_node.h.

◆ JBXL_ASN1_EXT

#define JBXL_ASN1_EXT   0x08

Definition at line 29 of file asn1_node.h.

◆ JBXL_ASN1_GNSTR

#define JBXL_ASN1_GNSTR   0x1b

Definition at line 47 of file asn1_node.h.

◆ JBXL_ASN1_GRSTR

#define JBXL_ASN1_GRSTR   0x19

Definition at line 45 of file asn1_node.h.

◆ JBXL_ASN1_GTM

#define JBXL_ASN1_GTM   0x18

Definition at line 44 of file asn1_node.h.

◆ JBXL_ASN1_IA5

#define JBXL_ASN1_IA5   0x16

Definition at line 42 of file asn1_node.h.

◆ JBXL_ASN1_INT

#define JBXL_ASN1_INT   0x02

Definition at line 23 of file asn1_node.h.

◆ JBXL_ASN1_NMSTR

#define JBXL_ASN1_NMSTR   0x12

Definition at line 38 of file asn1_node.h.

◆ JBXL_ASN1_NULL

#define JBXL_ASN1_NULL   0x05

Definition at line 26 of file asn1_node.h.

◆ JBXL_ASN1_OBJ

#define JBXL_ASN1_OBJ   0x06

Definition at line 27 of file asn1_node.h.

◆ JBXL_ASN1_OCT

#define JBXL_ASN1_OCT   0x04

Definition at line 25 of file asn1_node.h.

◆ JBXL_ASN1_OID

#define JBXL_ASN1_OID   0x0d

Definition at line 34 of file asn1_node.h.

◆ JBXL_ASN1_PRIMITIVE

#define JBXL_ASN1_PRIMITIVE   0x00

Definition at line 13 of file asn1_node.h.

◆ JBXL_ASN1_PRIVATE

#define JBXL_ASN1_PRIVATE   0xc0

Definition at line 19 of file asn1_node.h.

◆ JBXL_ASN1_PRSTR

#define JBXL_ASN1_PRSTR   0x13

Definition at line 39 of file asn1_node.h.

◆ JBXL_ASN1_REAL

#define JBXL_ASN1_REAL   0x09

Definition at line 30 of file asn1_node.h.

◆ JBXL_ASN1_SEQ

#define JBXL_ASN1_SEQ   0x10

Definition at line 35 of file asn1_node.h.

◆ JBXL_ASN1_SEQ_CNSTRCTD

#define JBXL_ASN1_SEQ_CNSTRCTD   0x30

Definition at line 52 of file asn1_node.h.

◆ JBXL_ASN1_SET

#define JBXL_ASN1_SET   0x11

Definition at line 36 of file asn1_node.h.

◆ JBXL_ASN1_SET_CNSTRCTD

#define JBXL_ASN1_SET_CNSTRCTD   0x31

Definition at line 53 of file asn1_node.h.

◆ JBXL_ASN1_TLSTR

#define JBXL_ASN1_TLSTR   0x14

Definition at line 40 of file asn1_node.h.

◆ JBXL_ASN1_UNIVERSAL

#define JBXL_ASN1_UNIVERSAL   0x00

Definition at line 16 of file asn1_node.h.

◆ JBXL_ASN1_UNSTR

#define JBXL_ASN1_UNSTR   0x1c

Definition at line 48 of file asn1_node.h.

◆ JBXL_ASN1_UTC

#define JBXL_ASN1_UTC   0x17

Definition at line 43 of file asn1_node.h.

◆ JBXL_ASN1_UTF8

#define JBXL_ASN1_UTF8   0x0c

Definition at line 33 of file asn1_node.h.

◆ JBXL_ASN1_VDSTR

#define JBXL_ASN1_VDSTR   0x15

Definition at line 41 of file asn1_node.h.

◆ JBXL_ASN1_VSSTR

#define JBXL_ASN1_VSSTR   0x1a

Definition at line 46 of file asn1_node.h.

Function Documentation

◆ asn1_id_type()

void asn1_id_type ( int  id,
int *  type,
int *  cnst,
int *  tag 
)

Definition at line 63 of file asn1_node.c.

64 {
65  if (cnst!=NULL) {
66  if (id & JBXL_ASN1_CNSTRCTD) *cnst = 1; // Constructed
67  else *cnst = 0;
68  }
69  if (type!=NULL) *type = (id & 0xc0) >> 6; // Class Type
70  if (tag!=NULL) *tag = id & 0x1f; // Tag
71 
72  return;
73 }
#define JBXL_ASN1_CNSTRCTD
CONSTRUCTED 構造化フラグ
Definition: asn1_node.h:14

References JBXL_ASN1_CNSTRCTD.

Referenced by asn1_print_id().

Here is the caller graph for this function:

◆ asn1_print_id()

void asn1_print_id ( FILE *  fp,
int  id 
)

Definition at line 76 of file asn1_node.c.

77 {
78  int cnst, type, tag;
79 
80  asn1_id_type(id, &type, &cnst, &tag);
81 
82  fprintf(fp, "[%02x] ", id); // Identifier data
83  fprintf(fp, "%s ", _ASN1_NODE_CLASS[type]); // Class
84  fprintf(fp, "%s ", _ASN1_NODE_CONST[cnst]); // Primitive/Constructed
85  if (type==0x00) fprintf(fp, "%s ", _ASN1_NODE_TAG[tag]); // Tag: if Class is UNIVERSAL
86  else fprintf(fp, "(%02x) ", tag); //
87 
88  return;
89 }
const char * _ASN1_NODE_TAG[]
Definition: asn1_node.c:26
const char * _ASN1_NODE_CLASS[]
Definition: asn1_node.c:10
const char * _ASN1_NODE_CONST[]
Definition: asn1_node.c:19
void asn1_id_type(int id, int *type, int *cnst, int *tag)
Definition: asn1_node.c:63

References _ASN1_NODE_CLASS, _ASN1_NODE_CONST, _ASN1_NODE_TAG, and asn1_id_type().

Referenced by print_tDER().

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

◆ asn1_print_tag_value()

void asn1_print_tag_value ( FILE *  fp,
int  tag,
Buffer  buf 
)

Definition at line 92 of file asn1_node.c.

93 {
94  if (buf.vldsz<=0) return;
95 
96  fprintf(fp, ": ");
97 
98  int tag = id & 0x1f;
99  if (tag==JBXL_ASN1_INT) {
100  long int n = bin2int_DER(buf);
101  fprintf(fp, "INT = %ld ", n);
102  }
103  else if (tag==JBXL_ASN1_OCT) {
104  if (buf.buf!=NULL) fprintf(fp, "\"%s\" ", buf.buf);
105  else fprintf(fp, "\"\" ");
106  }
107  else if (buf.buf!=NULL) { // その他
108  fprintf(fp, "....... ");
109  }
110  return;
111 }
#define JBXL_ASN1_INT
INTEGER.
Definition: asn1_node.h:23
#define JBXL_ASN1_OCT
OCTET_STRING.
Definition: asn1_node.h:25
long int bin2int_DER(Buffer buf)
Definition: asn1_tool.c:163
unsigned char ** buf
Definition: jpeg_tool.h:96

References bin2int_DER(), buf, JBXL_ASN1_INT, and JBXL_ASN1_OCT.

Referenced by print_tDER().

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