MCPcopy Create free account
hub / github.com/F-Stack/f-stack / cryptocteon_newsession

Function cryptocteon_newsession

freebsd/mips/cavium/cryptocteon/cryptocteon.c:176–239  ·  view source on GitHub ↗

Generate a new octo session. */

Source from the content-addressed store, hash-verified

174
175/* Generate a new octo session. */
176static int
177cryptocteon_newsession(device_t dev, crypto_session_t cses,
178 const struct crypto_session_params *csp)
179{
180 struct cryptocteon_softc *sc;
181 struct octo_sess *ocd;
182
183 sc = device_get_softc(dev);
184
185 ocd = crypto_get_driver_session(cses);
186
187 ocd->octo_encklen = csp->csp_cipher_klen;
188 if (csp->csp_cipher_key != NULL)
189 memcpy(ocd->octo_enckey, csp->csp_cipher_key,
190 ocd->octo_encklen);
191
192 if (csp->csp_auth_key != NULL)
193 cryptocteon_calc_hash(csp, csp->csp_auth_key, ocd);
194
195 ocd->octo_mlen = csp->csp_auth_mlen;
196 if (csp->csp_auth_mlen == 0) {
197 switch (csp->csp_auth_alg) {
198 case CRYPTO_SHA1_HMAC:
199 ocd->octo_mlen = SHA1_HASH_LEN;
200 break;
201 }
202 }
203
204 switch (csp->csp_mode) {
205 case CSP_MODE_DIGEST:
206 switch (csp->csp_auth_alg) {
207 case CRYPTO_SHA1_HMAC:
208 ocd->octo_encrypt = octo_null_sha1_encrypt;
209 ocd->octo_decrypt = octo_null_sha1_encrypt;
210 break;
211 }
212 break;
213 case CSP_MODE_CIPHER:
214 switch (csp->csp_cipher_alg) {
215 case CRYPTO_AES_CBC:
216 ocd->octo_encrypt = octo_aes_cbc_encrypt;
217 ocd->octo_decrypt = octo_aes_cbc_decrypt;
218 break;
219 }
220 break;
221 case CSP_MODE_ETA:
222 switch (csp->csp_cipher_alg) {
223 case CRYPTO_AES_CBC:
224 switch (csp->csp_auth_alg) {
225 case CRYPTO_SHA1_HMAC:
226 ocd->octo_encrypt = octo_aes_cbc_sha1_encrypt;
227 ocd->octo_decrypt = octo_aes_cbc_sha1_decrypt;
228 break;
229 }
230 break;
231 }
232 break;
233 }

Callers

nothing calls this directly

Calls 4

device_get_softcFunction · 0.85
cryptocteon_calc_hashFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected