summaryrefslogtreecommitdiffstats
path: root/userspace/ncrypto_params.c
blob: 0bbe0df44081db2d6d4cc084b39fc6e0673a8bc0 (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

#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "../ncr.h"
#include "ncrypto.h"

int
ncr_key_params_init(ncr_key_params_t *params)
{
	ncr_key_params_t rv;

	if (!params) {
		errno = EINVAL;
		return -1;
	}
	if (!(rv = calloc(1, sizeof(*rv)))) {
		errno = ENOMEM;
		return -1;
	}
	*params = rv;
	return 0;
}

void
ncr_key_params_deinit(ncr_key_params_t params)
{
	if (params)
		free(params);
}

int
ncr_key_params_set_cipher_iv(ncr_key_params_t params, void* iv, unsigned int iv_size)
{
	if (!params || (iv_size > NCR_CIPHER_MAX_BLOCK_LEN)) {
		errno = EINVAL;
		return -1;
	}
	memmove(params->params.cipher.iv, iv, iv_size);
	params->params.cipher.iv_size = iv_size;
	return 0;
}

int
ncr_key_params_set_dh_key(ncr_key_params_t params, ncr_key_t dh_priv)
{
	errno = EINVAL;
	return -1;
}