asn1_integer() ensures correct DER encoding of ASN1_INTEGER (two's complement)
This commit is contained in:
@@ -189,8 +189,8 @@ static bool matches_pubkey(chunk_t key, public_key_t *pubkey)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
pubkeydata = asn1_wrap(ASN1_SEQUENCE, "mm",
|
pubkeydata = asn1_wrap(ASN1_SEQUENCE, "mm",
|
||||||
asn1_wrap(ASN1_INTEGER, "c", n),
|
asn1_integer("c", n),
|
||||||
asn1_wrap(ASN1_INTEGER, "c", e));
|
asn1_integer("c", e));
|
||||||
hasher->allocate_hash(hasher, pubkeydata, &hash);
|
hasher->allocate_hash(hasher, pubkeydata, &hash);
|
||||||
free(pubkeydata.ptr);
|
free(pubkeydata.ptr);
|
||||||
id = pubkey->get_id(pubkey, ID_PUBKEY_SHA1);
|
id = pubkey->get_id(pubkey, ID_PUBKEY_SHA1);
|
||||||
@@ -387,8 +387,8 @@ static public_key_t* get_public_key(private_agent_private_key_t *this)
|
|||||||
e = read_string(&key);
|
e = read_string(&key);
|
||||||
n = read_string(&key);
|
n = read_string(&key);
|
||||||
encoded = asn1_wrap(ASN1_SEQUENCE, "mm",
|
encoded = asn1_wrap(ASN1_SEQUENCE, "mm",
|
||||||
asn1_wrap(ASN1_INTEGER, "c", n),
|
asn1_integer("c", n),
|
||||||
asn1_wrap(ASN1_INTEGER, "c", e));
|
asn1_integer("c", e));
|
||||||
|
|
||||||
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
public = lib->creds->create(lib->creds, CRED_PUBLIC_KEY, KEY_RSA,
|
||||||
BUILD_BLOB_ASN1_DER, encoded, BUILD_END);
|
BUILD_BLOB_ASN1_DER, encoded, BUILD_END);
|
||||||
@@ -440,8 +440,8 @@ static bool build_ids(private_agent_private_key_t *this)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
publicKey = asn1_wrap(ASN1_SEQUENCE, "mm",
|
publicKey = asn1_wrap(ASN1_SEQUENCE, "mm",
|
||||||
asn1_wrap(ASN1_INTEGER, "c", n),
|
asn1_integer("c", n),
|
||||||
asn1_wrap(ASN1_INTEGER, "c", e));
|
asn1_integer("c", e));
|
||||||
hasher->allocate_hash(hasher, publicKey, &hash);
|
hasher->allocate_hash(hasher, publicKey, &hash);
|
||||||
this->keyid = identification_create_from_encoding(ID_PUBKEY_SHA1, hash);
|
this->keyid = identification_create_from_encoding(ID_PUBKEY_SHA1, hash);
|
||||||
chunk_free(&hash);
|
chunk_free(&hash);
|
||||||
|
|||||||
@@ -317,14 +317,14 @@ static chunk_t get_encoding(private_gcrypt_rsa_private_key_t *this)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return asn1_wrap(ASN1_SEQUENCE, "cmmmmmmmm", ASN1_INTEGER_0,
|
return asn1_wrap(ASN1_SEQUENCE, "cmmmmmmmm", ASN1_INTEGER_0,
|
||||||
asn1_wrap(ASN1_INTEGER, "m", gcrypt_rsa_find_token(this->key, "n")),
|
asn1_integer("m", gcrypt_rsa_find_token(this->key, "n")),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", gcrypt_rsa_find_token(this->key, "e")),
|
asn1_integer("m", gcrypt_rsa_find_token(this->key, "e")),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", cd),
|
asn1_integer("m", cd),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", cp),
|
asn1_integer("m", cp),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", cq),
|
asn1_integer("m", cq),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", cexp1),
|
asn1_integer("m", cexp1),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", cexp2),
|
asn1_integer("m", cexp2),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", gcrypt_rsa_find_token(this->key, "u")));
|
asn1_integer("m", gcrypt_rsa_find_token(this->key, "u")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -393,8 +393,8 @@ bool gcrypt_rsa_build_keyids(gcry_sexp_t key, identification_t **keyid,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
publicKey = asn1_wrap(ASN1_SEQUENCE, "mm",
|
publicKey = asn1_wrap(ASN1_SEQUENCE, "mm",
|
||||||
asn1_wrap(ASN1_INTEGER, "m", gcrypt_rsa_find_token(key, "n")),
|
asn1_integer("m", gcrypt_rsa_find_token(key, "n")),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", gcrypt_rsa_find_token(key, "e")));
|
asn1_integer("m", gcrypt_rsa_find_token(key, "e")));
|
||||||
hasher->allocate_hash(hasher, publicKey, &hash);
|
hasher->allocate_hash(hasher, publicKey, &hash);
|
||||||
*keyid = identification_create_from_encoding(ID_PUBKEY_SHA1, hash);
|
*keyid = identification_create_from_encoding(ID_PUBKEY_SHA1, hash);
|
||||||
chunk_free(&hash);
|
chunk_free(&hash);
|
||||||
|
|||||||
@@ -216,8 +216,8 @@ static identification_t *get_id(private_gcrypt_rsa_public_key_t *this,
|
|||||||
static chunk_t get_encoding(private_gcrypt_rsa_public_key_t *this)
|
static chunk_t get_encoding(private_gcrypt_rsa_public_key_t *this)
|
||||||
{
|
{
|
||||||
return asn1_wrap(ASN1_SEQUENCE, "mm",
|
return asn1_wrap(ASN1_SEQUENCE, "mm",
|
||||||
asn1_wrap(ASN1_INTEGER, "m", gcrypt_rsa_find_token(this->key, "n")),
|
asn1_integer("m", gcrypt_rsa_find_token(this->key, "n")),
|
||||||
asn1_wrap(ASN1_INTEGER, "m", gcrypt_rsa_find_token(this->key, "e")));
|
asn1_integer("m", gcrypt_rsa_find_token(this->key, "e")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user