forked from cloudflare/keyless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkssl_private_key.h
62 lines (50 loc) · 2.5 KB
/
kssl_private_key.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
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
// kssl_private_key.h: private key storage for the keyless ssl
//
// Copyright (c) 2013 CloudFlare, Inc.
#ifndef INCLUDED_KSSL_PRIVATE_KEY
#define INCLUDED_KSSL_PRIVATE_KEY 1
#include "kssl.h"
// public definition of private key list
typedef struct pk_list_* pk_list;
// interface for private key list
// new_pk_list: initializes an array of private keys. Returns a
// pointer to an opaque structure. count is the number of private keys
// to allocate space for.
pk_list new_pk_list(int count);
// free_pk_list: frees an array of private keys created with a call
// to new_pk_list
void free_pk_list(pk_list list);
// add_key_from_file: adds an EVP key from a file location, returns
// KSSL_ERROR_NONE if successful, or a KSSL_ERROR_* if a problem
// occurs. Adds the private key to the list if successful.
kssl_error_code add_key_from_file(
const char *path, // Path to file containing key
pk_list list); // Array of private keys from new_pk_list
// add_key_from_buffer: adds an EVP key from a pointer, returns
// KSSL_ERROR_NONE if successful, or a KSSL_ERROR_* if a problem
// occurs. Adds the private key to the list if successful.
kssl_error_code add_key_from_buffer(
const char *key, // Key value in PEM format
int key_len, // Length of key in bytes
pk_list list); // Array of private keys
// find_private_key: returns an id for the key that matches the ski.
// In this implementation key id is the index into the list of privates.
// A negative return indicates an error.
int find_private_key(
pk_list list, // Array of private keys from new_pk_list
BYTE *ski, // SKI of key searched for (see get_ski)
BYTE *digest); // Digest of key searched for (see digest_public_key)
// private_key_operation: perform a private key operation
kssl_error_code private_key_operation(
pk_list list, // Private key array from new_pk_list
int key_id, // ID of key in pk_list from find_private_key
int opcode, // Opcode from a KSSL message indicating the operation
int length, // Length of data in message
BYTE *message, // Bytes to perform operation on
BYTE *out, // Buffer into which operation output is written
unsigned int *size); // Size of returned data written here
// key_size: returns the size of an EVP key in bytes
int key_size(
pk_list list, // Array of private keys from new_pk_list
int key_id); // ID of key from find_private_key
#endif // INCLUDED_KSSL_PRIVATE_KEY