summaryrefslogtreecommitdiff
path: root/lib/accelerated/x86/aes-padlock.h
blob: cff3128f147edee4c88cabf1cd4ff4000251de79 (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
#ifndef AES_PADLOCK_H
#define AES_PADLOCK_H

#include "gnutls_int.h"
#include <aes-x86.h>

struct padlock_cipher_data {
	unsigned char iv[16];	/* Initialization vector */
	union {
		unsigned int pad[4];
		struct {
			unsigned rounds:4;
			unsigned dgst:1;	/* n/a in C3 */
			unsigned align:1;	/* n/a in C3 */
			unsigned ciphr:1;	/* n/a in C3 */
			unsigned int keygen:1;
			unsigned interm:1;
			unsigned int encdec:1;
			unsigned ksize:2;
		} b;
	} cword;		/* Control word */
	AES_KEY ks;		/* Encryption key */
};

struct padlock_ctx {
	struct padlock_cipher_data expanded_key;
	int enc;
};

extern const gnutls_crypto_cipher_st _gnutls_aes_padlock;
extern const gnutls_crypto_cipher_st _gnutls_aes_gcm_padlock;

extern const gnutls_crypto_mac_st _gnutls_hmac_sha_padlock;
extern const gnutls_crypto_digest_st _gnutls_sha_padlock;

int padlock_aes_cipher_setkey(void *_ctx, const void *userkey,
			      size_t keysize);

/* asm */
unsigned int padlock_capability(void);
void padlock_reload_key(void);
int padlock_ecb_encrypt(void *out, const void *inp,
			struct padlock_cipher_data *ctx, size_t len);
int padlock_cbc_encrypt(void *out, const void *inp,
			struct padlock_cipher_data *ctx, size_t len);
#endif