#include <tommath.h>
#include "stdio.h"
#include <stdlib.h>
#include "string.h"
#include <tomcrypt.h>
#include "mySha.h"
#include "myEcdsa.h"
#include "utils.h"
Functions | |
void | computeAProbablePrimeFactorBasedOnAuxiliaryPrimes (mp_int *prime_out, mp_int *r1, mp_int *r2, mp_int *x, mp_int *e) |
void | generateKeyPairBasedOnAuxiliaryProbablePrimes (mp_int *p_out, mp_int *q_out, mp_int *n_out, mp_int *d_out, mp_int *xP1, mp_int *xP2, mp_int *xP, mp_int *xQ1, mp_int *xQ2, mp_int *xQ, mp_int *e) |
rsa_key | rsaKeyPair () |
產生RSA的key pair | |
char * | rsaSignMessage_pkcs1_v1_5 (const char *message, const int hashAlgo) |
產生RSA的簽章(pkcs1_v1_5) | |
char * | rsaSignMessage_pss (const char *message, const int hashAlgo) |
產生RSA的簽章(pss) | |
int | rsaVerifyMessage_pkcs1_v1_5 (const char *message, const char *signature, const int hashAlgo, rsa_key *key) |
驗證RSA的簽章(pkcs1_v1_5) | |
int | rsaVerifyMessage_pss (const char *message, const char *signature, const int hashAlgo, rsa_key *key) |
驗證RSA的簽章(pss) | |
Variables | |
mp_int | xP1 |
mp_int | xP2 |
mp_int | xP |
mp_int | xQ1 |
mp_int | xQ2 |
mp_int | xQ |
mp_int | e |
mp_int | p |
mp_int | q |
mp_int | n |
mp_int | d |
mp_int | dP |
mp_int | dQ |
mp_int | qP |
const int | RSA_SHA2_256 = 1 |
const int | RSA_SHA2_384 = 2 |
const int | RSA_SHA2_512 = 3 |
const int | RSA_SHA3_256 = 4 |
const int | RSA_SHA3_384 = 5 |
const int | RSA_SHA3_512 = 6 |
char | hex_signature [4096] |
void computeAProbablePrimeFactorBasedOnAuxiliaryPrimes | ( | mp_int * | prime_out, |
mp_int * | r1, | ||
mp_int * | r2, | ||
mp_int * | x, | ||
mp_int * | e ) |
void generateKeyPairBasedOnAuxiliaryProbablePrimes | ( | mp_int * | p_out, |
mp_int * | q_out, | ||
mp_int * | n_out, | ||
mp_int * | d_out, | ||
mp_int * | xP1, | ||
mp_int * | xP2, | ||
mp_int * | xP, | ||
mp_int * | xQ1, | ||
mp_int * | xQ2, | ||
mp_int * | xQ, | ||
mp_int * | e ) |
rsa_key rsaKeyPair | ( | ) |
產生RSA的key pair
產生RSA的key pair,回傳一個rsa_key struct 使用computeAProbablePrimeFactorBasedOnAuxiliaryPrimes()函數計算Probable Prime Factor Based On Auxiliary Primes 然後使用generateKeyPairBasedOnAuxiliaryProbablePrimes()函數產生key pair,以上是兩個rsaKeyPair()用到的內部函式 使用範例:
char * rsaSignMessage_pkcs1_v1_5 | ( | const char * | message, |
const int | hashAlgo ) |
產生RSA的簽章(pkcs1_v1_5)
產生RSA的簽章(pkcs1_v1_5),可以選擇不同的hash演算法
使用範例:
message | 要簽章的message |
hashAlgo | SHA2_256, SHA2_384, SHA2_512, SHA3_256, SHA3_384, SHA3_512, SHAKE128, SHAKE256 |
char * rsaSignMessage_pss | ( | const char * | message, |
const int | hashAlgo ) |
產生RSA的簽章(pss)
產生RSA的簽章(pss),可以選擇不同的hash演算法
使用範例:
message | 要簽章的message |
hashAlgo | SHA2_256, SHA2_384, SHA2_512, SHA3_256, SHA3_384, SHA3_512, SHAKE128, SHAKE256 |
int rsaVerifyMessage_pkcs1_v1_5 | ( | const char * | message, |
const char * | signature, | ||
const int | hashAlgo, | ||
rsa_key * | key ) |
驗證RSA的簽章(pkcs1_v1_5)
驗證RSA的簽章(pkcs1_v1_5),可以選擇不同的hash演算法
使用範例:
message | 要驗證的message |
signature | 簽章 |
hashAlgo | SHA2_256, SHA2_384, SHA2_512, SHA3_256, SHA3_384, SHA3_512, SHAKE128, SHAKE256 |
key | rsa_key struct 驗證需用到的公鑰 |
int rsaVerifyMessage_pss | ( | const char * | message, |
const char * | signature, | ||
const int | hashAlgo, | ||
rsa_key * | key ) |
驗證RSA的簽章(pss)
驗證RSA的簽章(pss),可以選擇不同的hash演算法
使用範例:
message | 要驗證的message |
signature | 簽章 |
hashAlgo | SHA2_256, SHA2_384, SHA2_512, SHA3_256, SHA3_384, SHA3_512, SHAKE128, SHAKE256 |
key | rsa_key struct 驗證需用到的公鑰 |
mp_int d |
mp_int dP |
mp_int dQ |
mp_int e |
char hex_signature[4096] |
mp_int n |
mp_int p |
mp_int q |
mp_int qP |
const int RSA_SHA2_256 = 1 |
const int RSA_SHA2_384 = 2 |
const int RSA_SHA2_512 = 3 |
const int RSA_SHA3_256 = 4 |
const int RSA_SHA3_384 = 5 |
const int RSA_SHA3_512 = 6 |
mp_int xP |
mp_int xP1 |
mp_int xP2 |
mp_int xQ |
mp_int xQ1 |
mp_int xQ2 |