Beispiel #1
0
void asn1_enc_init(ASN1_VALUE **pval, const ASN1_ITEM *it) {
  ASN1_ENCODING *enc;
  enc = asn1_get_enc_ptr(pval, it);
  if (enc) {
    enc->enc = NULL;
    enc->len = 0;
    enc->modified = 1;
  }
}
Beispiel #2
0
void asn1_enc_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
  ASN1_ENCODING *enc;
  enc = asn1_get_enc_ptr(pval, it);
  if (enc) {
    if (enc->enc) {
      OPENSSL_free(enc->enc);
    }
    enc->enc = NULL;
    enc->len = 0;
    enc->modified = 1;
  }
}
Beispiel #3
0
int asn1_enc_restore(int *len, unsigned char **out, ASN1_VALUE **pval, const ASN1_ITEM *it)
{
    ASN1_ENCODING *enc;
    enc = asn1_get_enc_ptr(pval, it);
    if(!enc || enc->modified) return 0;
    if(out) {
        memcpy(*out, enc->enc, enc->len);
        *out += enc->len;
    }
    if(len) *len = enc->len;
    return 1;
}
Beispiel #4
0
int asn1_enc_save(ASN1_VALUE **pval, unsigned char *in, int inlen, const ASN1_ITEM *it)
{
    ASN1_ENCODING *enc;
    enc = asn1_get_enc_ptr(pval, it);
    if(!enc) return 1;

    if(enc->enc) OPENSSL_free(enc->enc);
    enc->enc = OPENSSL_malloc(inlen);
    if(!enc->enc) return 0;
    memcpy(enc->enc, in, inlen);
    enc->len = inlen;
    enc->modified = 0;

    return 1;
}
Beispiel #5
0
int asn1_enc_save(ASN1_VALUE **pval, const uint8_t *in, int inlen,
                  const ASN1_ITEM *it)
{
    ASN1_ENCODING *enc;
    enc = asn1_get_enc_ptr(pval, it);
    if (!enc)
        return 1;

    if (enc->enc)
        free(enc->enc);
    enc->enc = malloc(inlen);
    if (!enc->enc)
        return 0;
    memcpy(enc->enc, in, inlen);
    enc->len = inlen;
    enc->modified = 0;

    return 1;
}