ASN1 NODE用ライブラリ. More...
#include "asn1_node.h"
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 [] |
Definition in file asn1_node.c.
void asn1_id_type | ( | int | id, | |
int * | type, | |||
int * | cnst, | |||
int * | tag | |||
) |
Definition at line 64 of file asn1_node.c.
References JBXL_ASN1_CNSTRCTD.
Referenced by asn1_print_id().
00065 { 00066 if (cnst!=NULL) { 00067 if (id & JBXL_ASN1_CNSTRCTD) *cnst = 1; // Constructed 00068 else *cnst = 0; 00069 } 00070 if (type!=NULL) *type = (id & 0xc0) >> 6; // Class Type 00071 if (tag!=NULL) *tag = id & 0x1f; // Tag 00072 00073 return; 00074 }
void asn1_print_id | ( | FILE * | fp, | |
int | id | |||
) |
Definition at line 77 of file asn1_node.c.
References _ASN1_NODE_CLASS, _ASN1_NODE_CONST, _ASN1_NODE_TAG, and asn1_id_type().
Referenced by print_tDER().
00078 { 00079 int cnst, type, tag; 00080 00081 asn1_id_type(id, &type, &cnst, &tag); 00082 00083 fprintf(fp, "[%02x] ", id); // Identifier data 00084 fprintf(fp, "%s ", _ASN1_NODE_CLASS[type]); // Class 00085 fprintf(fp, "%s ", _ASN1_NODE_CONST[cnst]); // Primitive/Constructed 00086 if (type==0x00) fprintf(fp, "%s ", _ASN1_NODE_TAG[tag]); // Tag: if Class is UNIVERSAL 00087 else fprintf(fp, "(%02x) ", tag); // 00088 00089 return; 00090 }
void asn1_print_tag_value | ( | FILE * | fp, | |
int | id, | |||
Buffer | buf | |||
) |
Definition at line 94 of file asn1_node.c.
References bin2int_DER(), Buffer::buf, JBXL_ASN1_INT, JBXL_ASN1_OCT, and Buffer::vldsz.
Referenced by print_tDER().
00095 { 00096 if (buf.vldsz<=0) return; 00097 00098 fprintf(fp, ": "); 00099 00100 int tag = id & 0x1f; 00101 if (tag==JBXL_ASN1_INT) { 00102 long int n = bin2int_DER(buf); 00103 fprintf(fp, "INT = %ld ", n); 00104 } 00105 else if (tag==JBXL_ASN1_OCT) { 00106 if (buf.buf!=NULL) fprintf(fp, "\"%s\" ", buf.buf); 00107 else fprintf(fp, "\"\" "); 00108 } 00109 else if (buf.buf!=NULL) { // その他 00110 fprintf(fp, "....... "); 00111 } 00112 00113 return; 00114 }
const char* _ASN1_NODE_CLASS[] |
{ "UNIVERSAL", "APPLICATION", "CONTEXT-DEFINED", "PRIVATE" }
Definition at line 10 of file asn1_node.c.
Referenced by asn1_print_id().
const char* _ASN1_NODE_CONST[] |
{ "PRIMITIVE", "CONSTRUCTED" }
Definition at line 19 of file asn1_node.c.
Referenced by asn1_print_id().
const char* _ASN1_NODE_TAG[] |
Definition at line 26 of file asn1_node.c.
Referenced by asn1_print_id().