5 int init
; /* 0 uninitialized */
13 struct crypto_ablkcipher
*s
;
14 struct ablkcipher_request
*request
;
17 struct crypto_aead
*as
;
18 struct aead_request
*arequest
;
20 struct cryptodev_result
*result
;
21 uint8_t iv
[EALG_MAX_BLOCK_LEN
];
25 int cryptodev_cipher_init(struct cipher_data
*out
, const char *alg_name
,
26 uint8_t *key
, size_t keylen
, int stream
, int aead
);
27 void cryptodev_cipher_deinit(struct cipher_data
*cdata
);
28 ssize_t
cryptodev_cipher_decrypt(struct cipher_data
*cdata
,
29 const struct scatterlist
*sg1
,
30 struct scatterlist
*sg2
, size_t len
);
31 ssize_t
cryptodev_cipher_encrypt(struct cipher_data
*cdata
,
32 const struct scatterlist
*sg1
,
33 struct scatterlist
*sg2
, size_t len
);
36 inline static void cryptodev_cipher_auth(struct cipher_data
*cdata
,
37 struct scatterlist
*sg1
, size_t len
)
40 aead_request_set_assoc(cdata
->async
.arequest
, sg1
, len
);
41 else /* for some reason we _have_ to call that */
42 aead_request_set_assoc(cdata
->async
.arequest
, NULL
, 0);
45 inline static void cryptodev_cipher_set_tag_size(struct cipher_data
*cdata
, int size
)
47 if (likely(cdata
->aead
!= 0))
48 crypto_aead_setauthsize(cdata
->async
.as
, size
);
51 inline static int cryptodev_cipher_get_tag_size(struct cipher_data
*cdata
)
53 if (likely(cdata
->init
&& cdata
->aead
!= 0))
54 return crypto_aead_authsize(cdata
->async
.as
);
59 inline static void cryptodev_cipher_set_iv(struct cipher_data
*cdata
,
60 void *iv
, size_t iv_size
)
62 memcpy(cdata
->async
.iv
, iv
, min(iv_size
, sizeof(cdata
->async
.iv
)));
65 inline static void cryptodev_cipher_get_iv(struct cipher_data
*cdata
,
66 void *iv
, size_t iv_size
)
68 memcpy(iv
, cdata
->async
.iv
, min(iv_size
, sizeof(cdata
->async
.iv
)));
73 int init
; /* 0 uninitialized */
77 struct crypto_ahash
*s
;
78 struct cryptodev_result
*result
;
79 struct ahash_request
*request
;
83 int cryptodev_hash_final(struct hash_data
*hdata
, void *output
);
84 ssize_t
cryptodev_hash_update(struct hash_data
*hdata
,
85 struct scatterlist
*sg
, size_t len
);
86 int cryptodev_hash_reset(struct hash_data
*hdata
);
87 void cryptodev_hash_deinit(struct hash_data
*hdata
);
88 int cryptodev_hash_init(struct hash_data
*hdata
, const char *alg_name
,
89 int hmac_mode
, void *mackey
, size_t mackeylen
);