aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustus Winter <justus@g10code.com>2016-05-02 16:00:23 +0200
committerAndreas Schneider <asn@cryptomilk.org>2016-11-03 15:19:34 +0100
commit3c2ea78a09fef43cc72fe6143b1bd6b10522c7f2 (patch)
tree2f57a76ad96cdbfd74b291ec0a6898fb86d1e9b7 /src
parent85bcfab71916979678bd40e233cf84297f08a686 (diff)
downloadlibssh-3c2ea78a09fef43cc72fe6143b1bd6b10522c7f2.tar.gz
libssh-3c2ea78a09fef43cc72fe6143b1bd6b10522c7f2.tar.xz
libssh-3c2ea78a09fef43cc72fe6143b1bd6b10522c7f2.zip
pki_gcrypt: Add a little more ASN1 infrastructure
* src/pki_gcrypt.c (ASN1_OCTET_STRING): New macro. (ASN1_OBJECT_IDENTIFIER): Likewise. (asn1_check_tag): New function. Signed-off-by: Justus Winter <justus@g10code.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r--src/pki_gcrypt.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pki_gcrypt.c b/src/pki_gcrypt.c
index 982e3f46..fefc0c13 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,19 @@ static int asn1_check_sequence(ssh_buffer buffer) {
return 1;
}
+static int asn1_check_tag(ssh_buffer buffer, unsigned char tag) {
+ unsigned char tmp;
+ uint32_t len;
+
+ len = ssh_buffer_get_data(buffer, &tmp, 1);
+ if (len == 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;