aboutsummaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/crypto.h
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2014-03-26 23:12:56 +0000
committerMichael Brown <mcb30@ipxe.org>2014-03-27 00:30:47 +0000
commit2dd3fffe18577baa9619623e627adacefd51fca9 (patch)
treefc9d2ac7a3e355846328d2570588f31849c43cdd /src/include/ipxe/crypto.h
parentc27b3c7c33630549696a672fbe3c085e8a522e53 (diff)
downloadipxe-2dd3fffe18577baa9619623e627adacefd51fca9.tar.gz
[crypto] Add pubkey_match() to check for matching public/private key pairs
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe/crypto.h')
-rw-r--r--src/include/ipxe/crypto.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/include/ipxe/crypto.h b/src/include/ipxe/crypto.h
index d7d42b66c..3eda5ec6e 100644
--- a/src/include/ipxe/crypto.h
+++ b/src/include/ipxe/crypto.h
@@ -157,6 +157,16 @@ struct pubkey_algorithm {
* @v ctx Context
*/
void ( * final ) ( void *ctx );
+ /** Check that public key matches private key
+ *
+ * @v private_key Private key
+ * @v private_key_len Private key length
+ * @v public_key Public key
+ * @v public_key_len Public key length
+ * @ret rc Return status code
+ */
+ int ( * match ) ( const void *private_key, size_t private_key_len,
+ const void *public_key, size_t public_key_len );
};
static inline void digest_init ( struct digest_algorithm *digest,
@@ -245,6 +255,14 @@ static inline void pubkey_final ( struct pubkey_algorithm *pubkey, void *ctx ) {
pubkey->final ( ctx );
}
+static inline int pubkey_match ( struct pubkey_algorithm *pubkey,
+ const void *private_key,
+ size_t private_key_len, const void *public_key,
+ size_t public_key_len ) {
+ return pubkey->match ( private_key, private_key_len, public_key,
+ public_key_len );
+}
+
extern struct digest_algorithm digest_null;
extern struct cipher_algorithm cipher_null;
extern struct pubkey_algorithm pubkey_null;