-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrsa.h
31 lines (23 loc) · 839 Bytes
/
rsa.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef TORHMC_RSA_H
#define TORHMC_RSA_H
#include <stdlib.h>
#include <iostream>
#include <cstring>
#include <string>
#include <sys/time.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include <openssl/engine.h>
#include <openssl/bn.h>
using namespace std;
int write_pubkey(RSA *key, char *filepath);
EVP_PKEY *read_pubkey(char *filepath);
int write_privkey(RSA *key, char *filepath);
EVP_PKEY *read_privkey(char *filepath);
unsigned char *rsa_encrypt(EVP_PKEY_CTX *en_ctx,
unsigned char *ptext, size_t &len);
unsigned char *rsa_decrypt(EVP_PKEY_CTX *de_ctx,
unsigned char *ctext, size_t &len);
unsigned char *randstr(unsigned char *str, int len, bool newseed=false);
#endif // TORHMC_RSA_H