make the sign/encrypt/decrypt opterations public.

git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2405 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
aj 2005-07-13 17:10:54 +00:00
parent 124b046d99
commit 19419bb3d1
4 changed files with 18 additions and 16 deletions

View File

@ -204,13 +204,5 @@ extern PKCS11_KEY_ops pkcs11_rsa_ops;
extern int pkcs11_find_key(PKCS11_CTX * ctx, PKCS11_KEY **key,
char* passphrase, char* s_slot_key_id, int verbose);
extern int pkcs11_sign(int type, const unsigned char *m, unsigned int m_len,
unsigned char *sigret, unsigned int *siglen, const PKCS11_KEY * key);
extern int pkcs11_private_encrypt(int flen, const unsigned char *from,
unsigned char *to, const PKCS11_KEY * rsa, int padding);
extern int pkcs11_private_decrypt(int flen, const unsigned char *from,
unsigned char *to, PKCS11_KEY * key, int padding);
extern int pkcs11_verify(int type, const unsigned char *m, unsigned int m_len,
unsigned char *signature, unsigned int siglen, PKCS11_KEY * key);
#endif

View File

@ -179,6 +179,17 @@ extern int PKCS11_init_pin(PKCS11_TOKEN *, char *pin);
extern int PKCS11_generate_key(PKCS11_TOKEN *, int, unsigned int, char *);
extern int PKCS11_store_private_key(PKCS11_TOKEN *, EVP_PKEY *, char *);
/* rsa private key operations */
extern int PKCS11_sign(int type, const unsigned char *m, unsigned int m_len,
unsigned char *sigret, unsigned int *siglen, const PKCS11_KEY * key);
extern int PKCS11_private_encrypt(int flen, const unsigned char *from,
unsigned char *to, const PKCS11_KEY * rsa, int padding);
extern int PKCS11_private_decrypt(int flen, const unsigned char *from,
unsigned char *to, PKCS11_KEY * key, int padding);
extern int PKCS11_verify(int type, const unsigned char *m, unsigned int m_len,
unsigned char *signature, unsigned int siglen, PKCS11_KEY * key);
/* Load PKCS11 error strings */
extern void ERR_load_PKCS11_strings(void);

View File

@ -62,9 +62,8 @@
#include <string.h>
#include "libp11-int.h"
int
pkcs11_sign(int type, const unsigned char *m, unsigned int m_len,
PKCS11_sign(int type, const unsigned char *m, unsigned int m_len,
unsigned char *sigret, unsigned int *siglen, const PKCS11_KEY * key)
{
@ -140,7 +139,7 @@ pkcs11_sign(int type, const unsigned char *m, unsigned int m_len,
int
pkcs11_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
PKCS11_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
const PKCS11_KEY * rsa, int padding)
{
/* PKCS11 calls go here */
@ -149,7 +148,7 @@ pkcs11_private_encrypt(int flen, const unsigned char *from, unsigned char *to,
}
int
pkcs11_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
PKCS11_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
PKCS11_KEY * key, int padding)
{
CK_RV rv;
@ -190,7 +189,7 @@ pkcs11_private_decrypt(int flen, const unsigned char *from, unsigned char *to,
}
int
pkcs11_verify(int type, const unsigned char *m, unsigned int m_len,
PKCS11_verify(int type, const unsigned char *m, unsigned int m_len,
unsigned char *signature, unsigned int siglen, PKCS11_KEY * key)
{

View File

@ -127,14 +127,14 @@ pkcs11_rsa_decrypt(int flen, const unsigned char *from, unsigned char *to,
RSA * rsa, int padding)
{
return pkcs11_private_decrypt( flen, from, to, (PKCS11_KEY *) RSA_get_app_data(rsa), padding);
return PKCS11_private_decrypt( flen, from, to, (PKCS11_KEY *) RSA_get_app_data(rsa), padding);
}
static int
pkcs11_rsa_encrypt(int flen, const unsigned char *from, unsigned char *to,
RSA * rsa, int padding)
{
return pkcs11_private_encrypt(flen,from,to,(PKCS11_KEY *) RSA_get_app_data(rsa), padding);
return PKCS11_private_encrypt(flen,from,to,(PKCS11_KEY *) RSA_get_app_data(rsa), padding);
}
static int
@ -142,7 +142,7 @@ pkcs11_rsa_sign(int type, const unsigned char *m, unsigned int m_len,
unsigned char *sigret, unsigned int *siglen, const RSA * rsa)
{
return pkcs11_sign(type,m,m_len,sigret,siglen,(PKCS11_KEY *) RSA_get_app_data(rsa));
return PKCS11_sign(type,m,m_len,sigret,siglen,(PKCS11_KEY *) RSA_get_app_data(rsa));
}
/* Lousy hack alert. If RSA_verify detects that the key has the
* RSA_FLAG_SIGN_VER flags set, it will assume that verification