Removed unnecessary failure handling.
}
static
-bool dcrypt_openssl_private_key_type(struct dcrypt_private_key *key, enum dcrypt_key_type *key_type)
+enum dcrypt_key_type dcrypt_openssl_private_key_type(struct dcrypt_private_key *key)
{
EVP_PKEY *priv = (EVP_PKEY*)key;
- if (priv == NULL) return FALSE;
- if (EVP_PKEY_base_id(priv) == EVP_PKEY_RSA) *key_type = DCRYPT_KEY_RSA;
- else if (EVP_PKEY_base_id(priv) == EVP_PKEY_EC) *key_type = DCRYPT_KEY_EC;
+ i_assert(priv != NULL);
+ if (EVP_PKEY_base_id(priv) == EVP_PKEY_RSA) return DCRYPT_KEY_RSA;
+ else if (EVP_PKEY_base_id(priv) == EVP_PKEY_EC) return DCRYPT_KEY_EC;
else i_unreached();
- return FALSE;
}
static
-bool dcrypt_openssl_public_key_type(struct dcrypt_public_key *key, enum dcrypt_key_type *key_type)
+enum dcrypt_key_type dcrypt_openssl_public_key_type(struct dcrypt_public_key *key)
{
EVP_PKEY *pub = (EVP_PKEY*)key;
- if (pub == NULL) return FALSE;
- if (EVP_PKEY_base_id(pub) == EVP_PKEY_RSA) *key_type = DCRYPT_KEY_RSA;
- else if (EVP_PKEY_base_id(pub) == EVP_PKEY_EC) *key_type = DCRYPT_KEY_EC;
+ i_assert(pub != NULL);
+ if (EVP_PKEY_base_id(pub) == EVP_PKEY_RSA) return DCRYPT_KEY_RSA;
+ else if (EVP_PKEY_base_id(pub) == EVP_PKEY_EC) return DCRYPT_KEY_EC;
else i_unreached();
- return FALSE;
}
/** this is the v1 old legacy way of doing key id's **/
const char *(*oid2name)(const unsigned char *oid, size_t oid_len, const char **error_r);
bool (*name2oid)(const char *name, buffer_t *oid, const char **error_r);
- bool (*private_key_type)(struct dcrypt_private_key *key, enum dcrypt_key_type *key_type);
- bool (*public_key_type)(struct dcrypt_public_key *key, enum dcrypt_key_type *key_type);
+ enum dcrypt_key_type (*private_key_type)(struct dcrypt_private_key *key);
+ enum dcrypt_key_type (*public_key_type)(struct dcrypt_public_key *key);
bool (*public_key_id)(struct dcrypt_public_key *key, const char *algorithm, buffer_t *result, const char **error_r);
bool (*public_key_id_old)(struct dcrypt_public_key *key, buffer_t *result, const char **error_r);
bool (*private_key_id)(struct dcrypt_private_key *key, const char *algorithm, buffer_t *result, const char **error_r);
encryption_key_hash_r, key_hash_r, error_r);
}
-bool dcrypt_key_type_private(struct dcrypt_private_key *key, enum dcrypt_key_type *type)
+enum dcrypt_key_type dcrypt_key_type_private(struct dcrypt_private_key *key)
{
- return dcrypt_vfs->private_key_type(key, type);
+ return dcrypt_vfs->private_key_type(key);
}
-bool dcrypt_key_type_public(struct dcrypt_public_key *key, enum dcrypt_key_type *type)
+enum dcrypt_key_type dcrypt_key_type_public(struct dcrypt_public_key *key)
{
- return dcrypt_vfs->public_key_type(key, type);
+ return dcrypt_vfs->public_key_type(key);
}
bool dcrypt_key_id_public(struct dcrypt_public_key *key, const char *algorithm, buffer_t *result, const char **error_r)
{
void dcrypt_key_free_public(struct dcrypt_public_key **key);
void dcrypt_key_free_private(struct dcrypt_private_key **key);
-bool dcrypt_key_type_private(struct dcrypt_private_key *key, enum dcrypt_key_type *type);
-bool dcrypt_key_type_public(struct dcrypt_public_key *key, enum dcrypt_key_type *type);
+enum dcrypt_key_type dcrypt_key_type_private(struct dcrypt_private_key *key);
+enum dcrypt_key_type dcrypt_key_type_public(struct dcrypt_public_key *key);
bool dcrypt_key_id_public(struct dcrypt_public_key *key, const char *algorithm, buffer_t *result, const char **error_r); /* return digest of key */
bool dcrypt_key_id_public_old(struct dcrypt_public_key *key, buffer_t *result, const char **error_r); /* return SHA1 sum of key */
bool dcrypt_key_id_private(struct dcrypt_private_key *key, const char *algorithm, buffer_t *result, const char **error_r); /* return digest of key */
encrypted_key = buffer_create_dynamic(pool_datastack_create(), 256);
temp_key = buffer_create_dynamic(pool_datastack_create(), 48);
- dcrypt_key_type_public(pubkey, &ktype);
+ ktype = dcrypt_key_type_public(pubkey);
if (ktype == DCRYPT_KEY_RSA) {
/* encrypt key as R (as we don't need DH with RSA)*/