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
)
39 /* for some reason we _have_ to call that even for zero length sgs */
40 aead_request_set_assoc(cdata
->async
.arequest
, len
? sg1
: NULL
, len
);
43 inline static void cryptodev_cipher_set_tag_size(struct cipher_data
*cdata
, int size
)
45 if (likely(cdata
->aead
!= 0))
46 crypto_aead_setauthsize(cdata
->async
.as
, size
);
49 inline static int cryptodev_cipher_get_tag_size(struct cipher_data
*cdata
)
51 if (likely(cdata
->init
&& cdata
->aead
!= 0))
52 return crypto_aead_authsize(cdata
->async
.as
);
57 inline static void cryptodev_cipher_set_iv(struct cipher_data
*cdata
,
58 void *iv
, size_t iv_size
)
60 memcpy(cdata
->async
.iv
, iv
, min(iv_size
, sizeof(cdata
->async
.iv
)));
63 inline static void cryptodev_cipher_get_iv(struct cipher_data
*cdata
,
64 void *iv
, size_t iv_size
)
66 memcpy(iv
, cdata
->async
.iv
, min(iv_size
, sizeof(cdata
->async
.iv
)));
71 int init
; /* 0 uninitialized */
75 struct crypto_ahash
*s
;
76 struct cryptodev_result
*result
;
77 struct ahash_request
*request
;
81 int cryptodev_hash_final(struct hash_data
*hdata
, void *output
);
82 ssize_t
cryptodev_hash_update(struct hash_data
*hdata
,
83 struct scatterlist
*sg
, size_t len
);
84 int cryptodev_hash_reset(struct hash_data
*hdata
);
85 void cryptodev_hash_deinit(struct hash_data
*hdata
);
86 int cryptodev_hash_init(struct hash_data
*hdata
, const char *alg_name
,
87 int hmac_mode
, void *mackey
, size_t mackeylen
);