Re: [PATCH v2 2/8] lib: add asn.1 encoder

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



James Bottomley <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx> wrote:

> +/**
> + * asn1_encode_octet_string - encode an ASN.1 OCTET STRING
> + * @data: pointer to encode at
> + * @data_len: bytes remaining in @data buffer
> + * @string: string to be encoded
> + * @len: length of string
> + *
> + * Note ASN.1 octet strings may contain zeros, so the length is obligatory.
> + */
> +int asn1_encode_octet_string(unsigned char **data, int *data_len,
> +			     const unsigned char *string, u32 len)

I wonder if it makes more sense to pass in an end pointer and return the new
data pointer (or an error), ie.:

unsigned char *asn1_encode_octet_string(unsigned char *data,
				        unsigned char *data_end,
					const unsigned char *string, u32 len)

Further, I wonder - does it actually make more sense to encode backwards,
ie. start at the end of the buffer and do the last element first, working
towards the front.

The disadvantage being that the data start would likely not be coincident with
the buffer start.

David




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux Kernel]     [Linux Kernel Hardening]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux