JunkBox_Lib  1.10.2
asn1_node.c File Reference

ASN1 NODE用ライブラリ More...

#include "asn1_node.h"
Include dependency graph for asn1_node.c:

Go to the source code of this file.

Functions

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

Variables

const char * _ASN1_NODE_CLASS []
 
const char * _ASN1_NODE_CONST []
 
const char * _ASN1_NODE_TAG []
 

Detailed Description

Author
Fumi.Iseki (C)

Definition in file asn1_node.c.

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  id,
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:

Variable Documentation

◆ _ASN1_NODE_CLASS

const char* _ASN1_NODE_CLASS[]
Initial value:
=
{
"UNIVERSAL",
"APPLICATION",
"CONTEXT-DEFINED",
"PRIVATE"
}

Definition at line 10 of file asn1_node.c.

Referenced by asn1_print_id().

◆ _ASN1_NODE_CONST

const char* _ASN1_NODE_CONST[]
Initial value:
=
{
"PRIMITIVE",
"CONSTRUCTED"
}

Definition at line 19 of file asn1_node.c.

Referenced by asn1_print_id().

◆ _ASN1_NODE_TAG

const char* _ASN1_NODE_TAG[]

Definition at line 26 of file asn1_node.c.

Referenced by asn1_print_id().