38 if ((
unsigned char)param.
buf[ls]==node) {
39 if ((
unsigned char)param.
buf[ls+1]>=0x80) {
40 sz = (int)param.
buf[ls+1] - 128;
42 for (i=ls+2; i<ls+sz+2; i++) {
44 *lp += (
unsigned char)param.
buf[i];
49 *lp = (int)param.
buf[ls+1];
80 memcpy(buf.
buf+pp, pt.
buf, sz);
103 buf.
buf[pp--] = sz % 256;
107 buf.
buf[pp] = (
unsigned char)sz;
108 buf.
buf[1] = 0x80 + cnt;
111 buf.
buf[1] = (
unsigned char)sz;
132 unsigned long int div;
145 bin.
buf[ii--] = (
unsigned char)(n % 256);
148 bin.
buf[0] = (
unsigned char)n;
151 if (n>0 && bin.
buf[0]>=0x80) {
152 for (ii=cnt; ii>0; ii--) bin.
buf[ii] = bin.
buf[ii-1];
165 if (buf.
buf==NULL || buf.
vldsz==0)
return 0;
169 unsigned char* pp = buf.
buf;
174 for (i=0; i<sz; i++) pp[i] = pp[i] ^ 0xff;
177 long int ret = pp[sz-1];
178 for (i=sz-2; i>=0; i--) {
181 if (minus) ret = - (ret + 1);
237 if (buf==NULL || buf->
buf==NULL)
return NULL;
242 der->ldat.lv = buf->
vldsz;
247 if (sz > buf->
vldsz)
return NULL;
257 if (der==NULL)
return;
258 if (buf==NULL) buf = &(der->ldat.val);
259 if (buf->
buf==NULL)
return;
261 unsigned char* pp = buf->
buf;
266 if (sz > buf->
vldsz - pos)
return;
282 }
while (pos<buf->vldsz);
300 if (der==NULL || buf==NULL)
return 0;
305 der->ldat.id = (int)(*buf);
307 der->ldat.val =
set_Buffer((
void*)(buf+cnt-len), len);
327 if (buf==NULL)
return 0;
335 int sz = (int)(*buf - 0x80);
338 for (i=0; i<sz; i++) {
339 len = len*256 + (int)(*buf);
350 if (valsz!=NULL) *valsz = len;
377 if (fp==NULL) fp = stderr;
380 while(pp->esis!=NULL) pp = pp->esis;
385 for(i=0; i<pp->depth; i++) fprintf(fp,
" ");
386 if (pp->depth>0) fprintf(fp,
" -> ");
387 fprintf(fp,
"%d: ", pp->depth);
389 fprintf(fp,
"%d, %d ", ld.lv, ld.val.vldsz);
402 fprintf(fp,
"(Tree is NULL)\n");
void asn1_print_id(FILE *fp, int id)
void asn1_print_tag_value(FILE *fp, int id, Buffer buf)
#define JBXL_ASN1_BIT
BIT_STRING.
#define JBXL_ASN1_INT
INTEGER.
#define JBXL_ASN1_CNSTRCTD
CONSTRUCTED 構造化フラグ
#define JBXL_ASN1_ANCHOR
ANCHOR.
Buffer make_Buffer(int sz)
Buffer型変数のバッファ部をつくり出す.
Buffer set_Buffer(void *dat, int len)
Buffer型変数のバッファ部を新しく作り, そのバッファに bufをコピーする.
void free_Buffer(Buffer *buf)
Buffer型変数のバッファ部を解放する
#define JBXL_STATE_ANCHOR
アンカーノード
int vldsz
データの長さ.バイナリデータの場合も使用可能.文字列の場合は 0x00 を含まない.
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.