added RSA preprocessor flags
parent
e54144536c
commit
211de19cc0
|
@ -1,3 +1,15 @@
|
||||||
|
#include <wolfssl/options.h>
|
||||||
|
#ifdef HAVE_ED25519
|
||||||
|
#include <wolfssl/wolfcrypt/ed25519.h>
|
||||||
|
#endif
|
||||||
|
#ifndef NO_RSA
|
||||||
|
#include <wolfssl/wolfcrypt/rsa.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ECC
|
||||||
|
#include <wolfssl/wolfcrypt/ecc.h>
|
||||||
|
#include <wolfssl/wolfcrypt/asn_public.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
RSA_SIGN,
|
RSA_SIGN,
|
||||||
ECC_SIGN,
|
ECC_SIGN,
|
||||||
|
@ -6,8 +18,9 @@ enum {
|
||||||
|
|
||||||
int wolfCLU_sign_data(char*, char*, char*, int);
|
int wolfCLU_sign_data(char*, char*, char*, int);
|
||||||
|
|
||||||
|
|
||||||
int wolfCLU_sign_data_rsa(byte*, char*, word32, char*);
|
int wolfCLU_sign_data_rsa(byte*, char*, word32, char*);
|
||||||
int wolfCLU_sign_data_ecc(byte*, char*, word32, byte*, word32, char*);
|
int wolfCLU_sign_data_ecc(byte*, char*, word32, char*);
|
||||||
int wolfCLU_sign_data_ed25519(byte*, char*, word32, byte*, word32, char*);
|
int wolfCLU_sign_data_ed25519(byte*, char*, word32, byte*, word32, char*);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,17 @@
|
||||||
|
#include <wolfssl/options.h>
|
||||||
|
#ifdef HAVE_ED25519
|
||||||
|
#include <wolfssl/wolfcrypt/ed25519.h>
|
||||||
|
#endif
|
||||||
|
#ifndef NO_RSA
|
||||||
|
#include <wolfssl/wolfcrypt/rsa.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_ECC
|
||||||
|
#include <wolfssl/wolfcrypt/ecc.h>
|
||||||
|
#include <wolfssl/wolfcrypt/asn_public.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int wolfCLU_verify_signature(char* , char*, char*, int, int);
|
int wolfCLU_verify_signature(char* , char*, char*, int, int);
|
||||||
|
|
||||||
int wolfCLU_verify_signature_rsa(byte* , char*, int, char*, int);
|
int wolfCLU_verify_signature_rsa(byte* , char*, int, char*, int);
|
||||||
int wolfCLU_verify_signature_ecc(byte*, int, char*);
|
int wolfCLU_verify_signature_ecc(byte*, int, byte*, int, char*);
|
||||||
int wolfCLU_verify_signature_ed25519(byte*, word32, char*);
|
int wolfCLU_verify_signature_ed25519(byte*, word32, char*);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include <wolfssl/options.h>
|
#include "clu_include/sign-verify/clu_sign.h"
|
||||||
#include <wolfssl/wolfcrypt/rsa.h>
|
|
||||||
#include <wolfssl/wolfcrypt/types.h>
|
#include <wolfssl/wolfcrypt/types.h>
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
#include "clu_include/sign-verify/clu_sign.h"
|
|
||||||
#include "clu_include/clu_header_main.h"
|
#include "clu_include/clu_header_main.h"
|
||||||
|
|
||||||
int wolfCLU_sign_data(char* in, char* out, char* privKey, int keyType) {
|
int wolfCLU_sign_data(char* in, char* out, char* privKey, int keyType) {
|
||||||
|
@ -39,6 +37,7 @@ int wolfCLU_sign_data(char* in, char* out, char* privKey, int keyType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int wolfCLU_sign_data_rsa(byte* data, char* out, word32 dataSz, char* privKey) {
|
int wolfCLU_sign_data_rsa(byte* data, char* out, word32 dataSz, char* privKey) {
|
||||||
|
#ifndef NO_RSA
|
||||||
int ret;
|
int ret;
|
||||||
int privFileSz;
|
int privFileSz;
|
||||||
size_t rsaKeySz;
|
size_t rsaKeySz;
|
||||||
|
@ -98,21 +97,12 @@ int wolfCLU_sign_data_rsa(byte* data, char* out, word32 dataSz, char* privKey) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
#else
|
||||||
|
return NOT_COMPILED_IN;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* working example
|
int wolfCLU_sign_data_ecc(byte* data, char* out, word32 fSz, char* privKey) {
|
||||||
|
|
||||||
int main() {
|
return 0;
|
||||||
FILE* f = fopen("./mydata.txt", "rb");
|
|
||||||
int f_Sz;
|
|
||||||
byte* data;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
f_Sz = ftell(f);
|
|
||||||
data = malloc(f_Sz*sizeof(data));
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fread(data, 1, f_Sz, f);
|
|
||||||
fclose(f);
|
|
||||||
wolfCLU_sign_data_rsa(data, f_Sz, "./myRsaKey4096.priv");
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#include <wolfssl/options.h>
|
#include "clu_include/sign-verify/clu_verify.h"
|
||||||
#include <wolfssl/wolfcrypt/rsa.h>
|
|
||||||
#include <wolfssl/wolfcrypt/types.h>
|
#include <wolfssl/wolfcrypt/types.h>
|
||||||
#include <wolfssl/ssl.h>
|
#include <wolfssl/ssl.h>
|
||||||
#include "clu_include/clu_header_main.h"
|
#include "clu_include/clu_header_main.h"
|
||||||
#include "clu_include/sign-verify/clu_verify.h"
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
RSA_SIGN,
|
RSA_SIGN,
|
||||||
|
@ -12,7 +10,7 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
byte* wolfCLU_generate_public_key(char* privKey, byte* outBuf, int* outBufSz) {
|
byte* wolfCLU_generate_public_key(char* privKey, byte* outBuf, int* outBufSz) {
|
||||||
|
#ifndef NO_RSA
|
||||||
int ret;
|
int ret;
|
||||||
int privFileSz;
|
int privFileSz;
|
||||||
word32 index = 0;
|
word32 index = 0;
|
||||||
|
@ -65,6 +63,10 @@ byte* wolfCLU_generate_public_key(char* privKey, byte* outBuf, int* outBufSz) {
|
||||||
}
|
}
|
||||||
*outBufSz = ret;
|
*outBufSz = ret;
|
||||||
return outBuf;
|
return outBuf;
|
||||||
|
#else
|
||||||
|
*outBufSz = NOT_COMPILED_IN;
|
||||||
|
return outBuf;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int wolfCLU_verify_signature(char* sig, char* out, char* keyPath, int keyType, int pubIn) {
|
int wolfCLU_verify_signature(char* sig, char* out, char* keyPath, int keyType, int pubIn) {
|
||||||
|
@ -97,6 +99,7 @@ int wolfCLU_verify_signature(char* sig, char* out, char* keyPath, int keyType, i
|
||||||
|
|
||||||
int wolfCLU_verify_signature_rsa(byte* sig, char* out, int sigSz, char* keyPath, int pubIn) {
|
int wolfCLU_verify_signature_rsa(byte* sig, char* out, int sigSz, char* keyPath, int pubIn) {
|
||||||
|
|
||||||
|
#ifndef NO_RSA
|
||||||
int ret;
|
int ret;
|
||||||
int keyFileSz;
|
int keyFileSz;
|
||||||
word32 index = 0;
|
word32 index = 0;
|
||||||
|
@ -154,26 +157,16 @@ int wolfCLU_verify_signature_rsa(byte* sig, char* out, int sigSz, char* keyPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
#else
|
||||||
|
printf("RSA is not compiled in.\n");
|
||||||
|
return NOT_COMPILED_IN;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int wolfCLU_sign_data_ecc(byte*, word32, byte*, word32, char*);
|
int wolfCLU_verify_signature_ecc(byte* sig, int sigSz, byte* hash, int hashSz,
|
||||||
|
char* keyPath) {
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int wolfCLU_sign_data_ed25519(byte*, word32, byte*, word32, char*);
|
int wolfCLU_sign_data_ed25519(byte*, word32, byte*, word32, char*);
|
||||||
|
|
||||||
/*
|
|
||||||
working example
|
|
||||||
int main() {
|
|
||||||
FILE* f = fopen("./signature.txt", "rb");
|
|
||||||
int f_Sz;
|
|
||||||
byte* data;
|
|
||||||
|
|
||||||
fseek(f, 0, SEEK_END);
|
|
||||||
f_Sz = ftell(f);
|
|
||||||
data = malloc(f_Sz*sizeof(data));
|
|
||||||
fseek(f, 0, SEEK_SET);
|
|
||||||
fread(data, 1, f_Sz, f);
|
|
||||||
fclose(f);
|
|
||||||
|
|
||||||
wolfCLU_verify_signature_rsa(data, f_Sz, "./myrsakey2048.priv", 0);
|
|
||||||
} */
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue