der flexi decoder: implement decoding of context-specific data
This commit is contained in:
parent
2d8933e4f1
commit
6bd6319fb0
@ -108,6 +108,12 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc
|
|||||||
/* treat constructed elements like SETs */
|
/* treat constructed elements like SETs */
|
||||||
type = 0x20;
|
type = 0x20;
|
||||||
}
|
}
|
||||||
|
else if ((type & 0xC0) == 0x80) {
|
||||||
|
/* context-specific, use the 'used' field to store the original identifier */
|
||||||
|
l->used = type;
|
||||||
|
/* context-specific elements are treated as opaque data */
|
||||||
|
type = 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
/* now switch on type */
|
/* now switch on type */
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -359,6 +365,20 @@ int der_decode_sequence_flexi(const unsigned char *in, unsigned long *inlen, ltc
|
|||||||
l->child->parent = l;
|
l->child->parent = l;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 0x80: /* Context-specific */
|
||||||
|
l->type = LTC_ASN1_CONTEXT_SPECIFIC;
|
||||||
|
|
||||||
|
if ((l->data = XCALLOC(1, len - data_offset)) == NULL) {
|
||||||
|
err = CRYPT_MEM;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
XMEMCPY(l->data, in + data_offset, len - data_offset);
|
||||||
|
l->size = len - data_offset;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* invalid byte ... this is a soft error */
|
/* invalid byte ... this is a soft error */
|
||||||
/* remove link */
|
/* remove link */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user