summaryrefslogtreecommitdiff
path: root/other/wrez/isolation/cipher-mrsa-interface.h
blob: 21439451a4838dbe2b424c67c17d107ca415e0d6 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79

#ifndef	CIPHER_MRSA_INTERFACE_H
#define	CIPHER_MRSA_INTERFACE_H

#include "cipher-mrsa.h"


typedef struct {
	NN	pq;	/* n = p * q */
	NN	e;	/* public exponent */
} rsa_pubkey;

typedef struct {
	NN	d;	/* private exponent */
	NN	p, q;
	NN	dp, dq, qp;
} rsa_privkey;


/* rsa_keypair_generate
 *
 * generate a 512 bit rsa keypair and copy only required components into the
 * appropiate structure.
 *
 * return 0 on success
 * return != 0 on failure
 */

int
rsa_keypair_generate (rsa_pubkey *pub, rsa_privkey *priv);


/* rsa_keypair_dump
 *
 * output the two keys in human readable form to `fd'. when they are set to
 * NULL, they are not exported.
 *
 * return in any case
 */

void
rsa_keypair_dump (int fd, rsa_pubkey *pub, rsa_privkey *priv);


/* rsa_keypair_import
 *
 * import a 512 bit rsa keypair from `fd' in human readable format to the
 * `pub' and `priv' structures. each can be set to NULL to skip them.
 *
 * return in any case
 */

void
rsa_keypair_import (int fd, rsa_pubkey *pub, rsa_privkey *priv);


/* rsa_encrypt
 *
 * encrypt RSA_SIZE byte array at `data' with the public key `pub'.
 *
 * return in any case
 */

void
rsa_encrypt (rsa_pubkey *pub, unsigned char *data);


/* rsa_decrypt
 *
 * decrypt RSA_SIZE byte array at `data' with the private key `priv'.
 *
 * return in any case
 */

void
rsa_decrypt (rsa_privkey *priv, unsigned char *data);

#endif