Add RSA-alt to the PK layer
diff --git a/library/pk.c b/library/pk.c
index 6e60574..e0a252f 100644
--- a/library/pk.c
+++ b/library/pk.c
@@ -84,6 +84,7 @@
case POLARSSL_PK_ECDSA:
return &ecdsa_info;
#endif
+ /* POLARSSL_PK_RSA_ALT ommited on purpose */
default:
return NULL;
}
@@ -106,6 +107,35 @@
}
/*
+ * Initialize an RSA-alt context
+ */
+int pk_init_ctx_rsa_alt( pk_context *ctx, void * key,
+ pk_rsa_alt_decrypt_func decrypt_func,
+ pk_rsa_alt_sign_func sign_func,
+ pk_rsa_alt_key_len_func key_len_func )
+{
+ rsa_alt_context *rsa_alt;
+ const pk_info_t *info = &rsa_alt_info;
+
+ if( ctx == NULL || ctx->pk_info != NULL )
+ return( POLARSSL_ERR_PK_BAD_INPUT_DATA );
+
+ if( ( ctx->pk_ctx = info->ctx_alloc_func() ) == NULL )
+ return( POLARSSL_ERR_PK_MALLOC_FAILED );
+
+ ctx->pk_info = info;
+
+ rsa_alt = (rsa_alt_context *) ctx->pk_ctx;
+
+ rsa_alt->key = key;
+ rsa_alt->decrypt_func = decrypt_func;
+ rsa_alt->sign_func = sign_func;
+ rsa_alt->key_len_func = key_len_func;
+
+ return( 0 );
+}
+
+/*
* Tell if a PK can do the operations of the given type
*/
int pk_can_do( pk_context *ctx, pk_type_t type )