util.h
1.3 KB
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
#include <stdio.h>
#include <string.h>
#include <openssl/rsa.h>
#include <openssl/bn.h>
#include <openssl/rand.h>
#include <netinet/in.h>
#include <bb_nn.h>
#include <sha1.h>
#include <PR/bbcert.h>
#include <PR/bbcrl.h>
#include <PR/bbticket.h>
#define MAX_KEY_SIZE 4096
#define get_word(x) *(u32*)(x)
void readRsaData(FILE *readptr, RSA *prsa);
void saveRsaData(FILE *writeptr, RSA *prsa);
void readRsaDataNamed(FILE *readptr, RSA *prsa, BbServerName name);
void saveRsaDataNamed(FILE *writeptr, RSA *prsa, BbServerName name);
/* takes in key material, signs random data and verifies using libcryptoX86
*/
int validate(RSA *prsa, int num_bits);
/* takes in byte strings from openssl
* and converts to host word order
*/
void convertToHost(u8 *e_string, u8 *n_string, u8 *sign,
int e_size, int n_size,
u32 *certexponent, u32 *certpublickey, u32 *certsign);
int verifyCertSign( void *subjectcert, int subjectsize,
u32 signerexponent,
u8 *signerpublic, int signerpublicsize);
void
generateCertFromKeyData(u8 *keydatafile, u8 *signerkeydatafile, u8 *subjectname, u8 *issuername, unsigned long *certdata);
void
signRsa(u8 *hash_data, RSA * prsa2, unsigned long *certsign);
int verifyTicketSig(BbTicket *ticket, BbRsaCert *signer);
int verifyRlSig(BbCrlHead *head, u8 *crl, BbRsaCert *signer);