[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/5] pki_gcrypt: Add a little more ASN1 infrastructure
[Thread Prev] | [Thread Next]
- Subject: [PATCH 2/5] pki_gcrypt: Add a little more ASN1 infrastructure
- From: Justus Winter <justus@xxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Mon, 2 May 2016 16:00:23 +0200
- To: libssh@xxxxxxxxxx
- Cc: Justus Winter <justus@xxxxxxxxxxx>
* src/pki_gcrypt.c (ASN1_OCTET_STRING): New macro. (ASN1_OBJECT_IDENTIFIER): Likewise. (asn1_check_tag): New function. Signed-off-by: Justus Winter <justus@xxxxxxxxxxx> --- src/pki_gcrypt.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c index 982e3f4..acfed2e 100644 --- a/src/pki_gcrypt.c +++ b/src/pki_gcrypt.c @@ -50,6 +50,8 @@ #define MAX_PASSPHRASE_SIZE 1024 #define ASN1_INTEGER 2 #define ASN1_BIT_STRING 3 +#define ASN1_OCTET_STRING 4 +#define ASN1_OBJECT_IDENTIFIER 6 #define ASN1_SEQUENCE 48 #define PKCS5_SALT_LEN 8 @@ -228,6 +230,17 @@ static int asn1_check_sequence(ssh_buffer buffer) { return 1; } +static int asn1_check_tag(ssh_buffer buffer, unsigned char tag) { + unsigned char tmp; + + if (ssh_buffer_get_data(buffer, &tmp, 1) == 0 || tmp != tag) { + return 0; + } + + (void) asn1_get_len(buffer); + return 1; +} + static int passphrase_to_key(char *data, unsigned int datalen, unsigned char *salt, unsigned char *key, unsigned int keylen) { MD5CTX md; -- 2.8.1
Re: [PATCH 2/3] pki_gcrypt: Handle ECDSA keys and signatures | Andreas Schneider <asn@xxxxxxxxxxxxxx> |
[PATCH 1/5] curve25519: Small libgcrypt bignum fix | Justus Winter <justus@xxxxxxxxxxx> |