asn1: export 'asn1-write-element' function
... used by OpenPGP driver
This commit is contained in:
parent
42ad3c1dff
commit
0518ced8e0
|
@ -34,6 +34,8 @@ static int asn1_decode(sc_context_t *ctx, struct sc_asn1_entry *asn1,
|
|||
int choice, int depth);
|
||||
static int asn1_encode(sc_context_t *ctx, const struct sc_asn1_entry *asn1,
|
||||
u8 **ptr, size_t *size, int depth);
|
||||
static int asn1_write_element(sc_context_t *ctx, unsigned int tag,
|
||||
const u8 * data, size_t datalen, u8 ** out, size_t * outlen);
|
||||
|
||||
static const char *tag2str(unsigned int tag)
|
||||
{
|
||||
|
@ -754,6 +756,12 @@ int sc_asn1_put_tag(int tag, const u8 * data, size_t datalen, u8 * out, size_t o
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sc_asn1_write_element(sc_context_t *ctx, unsigned int tag,
|
||||
const u8 * data, size_t datalen, u8 ** out, size_t * outlen)
|
||||
{
|
||||
return asn1_write_element(ctx, tag, data, datalen, out, outlen);
|
||||
}
|
||||
|
||||
static int asn1_write_element(sc_context_t *ctx, unsigned int tag,
|
||||
const u8 * data, size_t datalen, u8 ** out, size_t * outlen)
|
||||
{
|
||||
|
|
|
@ -111,6 +111,11 @@ int sc_asn1_encode_algorithm_id(struct sc_context *,
|
|||
const struct sc_algorithm_id *, int);
|
||||
void sc_asn1_clear_algorithm_id(struct sc_algorithm_id *);
|
||||
|
||||
|
||||
/* ASN.1 object encoding functions */
|
||||
int sc_asn1_write_element(sc_context_t *ctx, unsigned int tag,
|
||||
const u8 * data, size_t datalen, u8 ** out, size_t * outlen);
|
||||
|
||||
#define SC_ASN1_CLASS_MASK 0x30000000
|
||||
#define SC_ASN1_UNI 0x00000000 /* Universal */
|
||||
#define SC_ASN1_APP 0x10000000 /* Application */
|
||||
|
|
|
@ -1818,9 +1818,9 @@ pgp_build_tlv(sc_context_t *ctx, unsigned int tag, u8 *data, size_t len, u8 **ou
|
|||
u8 highest_order = 0;
|
||||
u8 cla;
|
||||
int r;
|
||||
r = asn1_write_element(ctx, tag, data, len, out, outlen);
|
||||
r = sc_asn1_write_element(ctx, tag, data, len, out, outlen);
|
||||
LOG_TEST_RET(ctx, r, "Failed to write ASN.1 element");
|
||||
/* Restore class bits stripped by asn1_write_element */
|
||||
/* Restore class bits stripped by sc_asn1_write_element */
|
||||
/* Determine the left most byte of tag, which contains class bits */
|
||||
while (tag >> 8*highest_order) {
|
||||
highest_order++;
|
||||
|
|
|
@ -49,6 +49,7 @@ sc_asn1_print_tags
|
|||
sc_asn1_put_tag
|
||||
sc_asn1_skip_tag
|
||||
sc_asn1_verify_tag
|
||||
sc_asn1_write_element
|
||||
sc_base64_decode
|
||||
sc_base64_encode
|
||||
sc_bin_to_hex
|
||||
|
|
Loading…
Reference in New Issue