summaryrefslogtreecommitdiff
path: root/lib/accelerated/x86/aes-padlock.h
blob: ccb8359af319aa428c2bdbe48ff57f5e8020ef4c (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 {
            int rounds:4;
            int dgst:1;         /* n/a in C3 */
            int align:1;        /* n/a in C3 */
            int ciphr:1;        /* n/a in C3 */
            unsigned int keygen:1;
            int interm:1;
            unsigned int encdec:1;
            int 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 aes_gcm_padlock_struct;
extern const gnutls_crypto_mac_st hmac_sha_padlock_struct;
extern const gnutls_crypto_digest_st sha_padlock_struct;

extern const gnutls_crypto_mac_st hmac_sha_padlock_nano_struct;
extern const gnutls_crypto_digest_st sha_padlock_nano_struct;

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