};
/**
- * Build an EMSA PSS signature described in PKCS#1
+ * Get the Botan string identifier for an EMSA PSS signature
*/
-static bool build_emsa_pss_signature(private_botan_rsa_private_key_t *this,
- rsa_pss_params_t *params, chunk_t data,
- chunk_t *sig)
+bool botan_emsa_pss_identifier(rsa_pss_params_t *params, char *id, size_t len)
{
const char *hash;
- char hash_and_padding[BUF_LEN];
if (!params)
{
if (params->salt_len > RSA_PSS_SALT_LEN_DEFAULT)
{
- snprintf(hash_and_padding, sizeof(hash_and_padding),
- "EMSA-PSS(%s,MGF1,%u)", hash, params->salt_len);
+ return snprintf(id, len, "EMSA-PSS(%s,MGF1,%zd)", hash,
+ params->salt_len) < len;
}
- else
+ return snprintf(id, len, "EMSA-PSS(%s,MGF1)", hash) < len;
+}
+
+/**
+ * Build an EMSA PSS signature described in PKCS#1
+ */
+static bool build_emsa_pss_signature(private_botan_rsa_private_key_t *this,
+ rsa_pss_params_t *params, chunk_t data,
+ chunk_t *sig)
+{
+ char hash_and_padding[BUF_LEN];
+
+ if (!botan_emsa_pss_identifier(params, hash_and_padding,
+ sizeof(hash_and_padding)))
{
- snprintf(hash_and_padding, sizeof(hash_and_padding),
- "EMSA-PSS(%s,MGF1)", hash);
+ return FALSE;
}
return botan_get_signature(this->key, hash_and_padding, data, sig);
}
refcount_t ref;
};
+/**
+ * Defined in botan_rsa_private_key.c
+ */
+bool botan_emsa_pss_identifier(rsa_pss_params_t *params, char *id, size_t len);
+
/**
* Verify RSA signature
*/
rsa_pss_params_t *params, chunk_t data,
chunk_t signature)
{
- const char *hash;
char hash_and_padding[BUF_LEN];
- if (!params)
- {
- return FALSE;
- }
-
- /* botan currently does not support passing the mgf1 hash */
- if (params->hash != params->mgf1_hash)
- {
- DBG1(DBG_LIB, "passing mgf1 hash not supported via botan");
- return FALSE;
- }
-
- hash = botan_get_hash(params->hash);
- if (!hash)
+ if (!botan_emsa_pss_identifier(params, hash_and_padding,
+ sizeof(hash_and_padding)))
{
return FALSE;
}
-
- if (params->salt_len > RSA_PSS_SALT_LEN_DEFAULT)
- {
- snprintf(hash_and_padding, sizeof(hash_and_padding),
- "EMSA-PSS(%s,MGF1,%u)", hash, params->salt_len);
- }
- else
- {
- snprintf(hash_and_padding, sizeof(hash_and_padding),
- "EMSA-PSS(%s,MGF1)", hash);
- }
return verify_rsa_signature(this, hash_and_padding, data, signature);
}