Commit 64bb6b36 authored by Niels Möller's avatar Niels Möller

Use size_t for asn1 parser.

parent c9460c81
...@@ -93,23 +93,23 @@ enum asn1_iterator_result ...@@ -93,23 +93,23 @@ enum asn1_iterator_result
/* Parsing DER objects. */ /* Parsing DER objects. */
struct asn1_der_iterator struct asn1_der_iterator
{ {
unsigned buffer_length; size_t buffer_length;
const uint8_t *buffer; const uint8_t *buffer;
/* Next object to parse. */ /* Next object to parse. */
unsigned pos; size_t pos;
enum asn1_type type; enum asn1_type type;
/* Pointer to the current object */ /* Pointer to the current object */
unsigned length; size_t length;
const uint8_t *data; const uint8_t *data;
}; };
/* Initializes the iterator. */ /* Initializes the iterator. */
enum asn1_iterator_result enum asn1_iterator_result
asn1_der_iterator_first(struct asn1_der_iterator *iterator, asn1_der_iterator_first(struct asn1_der_iterator *iterator,
unsigned length, const uint8_t *input); size_t length, const uint8_t *input);
enum asn1_iterator_result enum asn1_iterator_result
asn1_der_iterator_next(struct asn1_der_iterator *iterator); asn1_der_iterator_next(struct asn1_der_iterator *iterator);
......
...@@ -87,7 +87,7 @@ enum { ...@@ -87,7 +87,7 @@ enum {
* first element. */ * first element. */
static void static void
asn1_der_iterator_init(struct asn1_der_iterator *iterator, asn1_der_iterator_init(struct asn1_der_iterator *iterator,
unsigned length, const uint8_t *input) size_t length, const uint8_t *input)
{ {
iterator->buffer_length = length; iterator->buffer_length = length;
iterator->buffer = input; iterator->buffer = input;
...@@ -133,7 +133,7 @@ asn1_der_iterator_next(struct asn1_der_iterator *i) ...@@ -133,7 +133,7 @@ asn1_der_iterator_next(struct asn1_der_iterator *i)
if (LEFT(i) < k) if (LEFT(i) < k)
return ASN1_ITERATOR_ERROR; return ASN1_ITERATOR_ERROR;
if (k > sizeof(unsigned)) if (k > sizeof(i->length))
return ASN1_ITERATOR_ERROR; return ASN1_ITERATOR_ERROR;
i->pos += k; i->pos += k;
...@@ -164,7 +164,7 @@ asn1_der_iterator_next(struct asn1_der_iterator *i) ...@@ -164,7 +164,7 @@ asn1_der_iterator_next(struct asn1_der_iterator *i)
enum asn1_iterator_result enum asn1_iterator_result
asn1_der_iterator_first(struct asn1_der_iterator *i, asn1_der_iterator_first(struct asn1_der_iterator *i,
unsigned length, const uint8_t *input) size_t length, const uint8_t *input)
{ {
asn1_der_iterator_init(i, length, input); asn1_der_iterator_init(i, length, input);
return asn1_der_iterator_next(i); return asn1_der_iterator_next(i);
...@@ -216,7 +216,7 @@ asn1_der_get_uint32(struct asn1_der_iterator *i, ...@@ -216,7 +216,7 @@ asn1_der_get_uint32(struct asn1_der_iterator *i,
/* Big endian, two's complement, minimum number of octets (except 0, /* Big endian, two's complement, minimum number of octets (except 0,
which is encoded as a single octet */ which is encoded as a single octet */
uint32_t value = 0; uint32_t value = 0;
unsigned length = i->length; size_t length = i->length;
unsigned k; unsigned k;
if (!length || length > 5) if (!length || length > 5)
......
...@@ -103,9 +103,9 @@ dsa_openssl_private_key_from_der_iterator(struct dsa_public_key *pub, ...@@ -103,9 +103,9 @@ dsa_openssl_private_key_from_der_iterator(struct dsa_public_key *pub,
int int
dsa_openssl_private_key_from_der(struct dsa_public_key *pub, dsa_openssl_private_key_from_der(struct dsa_public_key *pub,
struct dsa_private_key *priv, struct dsa_private_key *priv,
unsigned p_max_bits, unsigned p_max_bits,
unsigned length, const uint8_t *data) size_t length, const uint8_t *data)
{ {
struct asn1_der_iterator i; struct asn1_der_iterator i;
enum asn1_iterator_result res; enum asn1_iterator_result res;
......
...@@ -116,7 +116,7 @@ int ...@@ -116,7 +116,7 @@ int
rsa_keypair_from_der(struct rsa_public_key *pub, rsa_keypair_from_der(struct rsa_public_key *pub,
struct rsa_private_key *priv, struct rsa_private_key *priv,
unsigned limit, unsigned limit,
unsigned length, const uint8_t *data) size_t length, const uint8_t *data)
{ {
struct asn1_der_iterator i; struct asn1_der_iterator i;
enum asn1_iterator_result res; enum asn1_iterator_result res;
......
...@@ -268,7 +268,7 @@ int ...@@ -268,7 +268,7 @@ int
dsa_openssl_private_key_from_der(struct dsa_public_key *pub, dsa_openssl_private_key_from_der(struct dsa_public_key *pub,
struct dsa_private_key *priv, struct dsa_private_key *priv,
unsigned p_max_bits, unsigned p_max_bits,
unsigned length, const uint8_t *data); size_t length, const uint8_t *data);
/* Internal functions. */ /* Internal functions. */
......
...@@ -386,7 +386,7 @@ int ...@@ -386,7 +386,7 @@ int
rsa_keypair_from_der(struct rsa_public_key *pub, rsa_keypair_from_der(struct rsa_public_key *pub,
struct rsa_private_key *priv, struct rsa_private_key *priv,
unsigned limit, unsigned limit,
unsigned length, const uint8_t *data); size_t length, const uint8_t *data);
/* OpenPGP format. Experimental interface, subject to change. */ /* OpenPGP format. Experimental interface, subject to change. */
int int
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment