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