Lines Matching defs:sav
226 esp_schedule(algo, sav)
228 struct secasvar *sav;
233 if (_KEYBITS(sav->key_enc) < algo->keymin ||
234 _KEYBITS(sav->key_enc) > algo->keymax) {
237 "needs %d to %d bits\n", algo->name, _KEYBITS(sav->key_enc),
244 if (sav->sched && sav->schedlen != 0) {
254 sav->schedlen = (*algo->schedlen)(algo);
255 if (sav->schedlen < 0) {
261 sav->sched = _MALLOC(sav->schedlen, M_SECA, M_DONTWAIT);
262 if (!sav->sched) {
263 sav->schedlen = 0;
268 error = (*algo->schedule)(algo, sav);
272 bzero(sav->sched, sav->schedlen);
273 FREE(sav->sched, M_SECA);
274 sav->sched = NULL;
275 sav->schedlen = 0;
283 __unused struct secasvar *sav)
294 __unused struct secasvar *sav,
307 __unused struct secasvar *sav,
316 esp_descbc_mature(sav)
317 struct secasvar *sav;
321 if (!(sav->flags & SADB_X_EXT_OLD) && (sav->flags & SADB_X_EXT_IV4B)) {
327 if (!sav->key_enc) {
332 algo = esp_algorithm_lookup(sav->alg_enc);
339 if (_KEYBITS(sav->key_enc) < algo->keymin ||
340 _KEYBITS(sav->key_enc) > algo->keymax) {
343 _KEYBITS(sav->key_enc)));
348 if (des_is_weak_key((des_cblock *)_KEYBUF(sav->key_enc))) {
360 struct secasvar *sav)
363 if (!sav)
365 if ((sav->flags & SADB_X_EXT_OLD) && (sav->flags & SADB_X_EXT_IV4B))
367 if (!(sav->flags & SADB_X_EXT_OLD) && (sav->flags & SADB_X_EXT_DERIV))
383 struct secasvar *sav)
387 if (des_key_sched((des_cblock *)_KEYBUF(sav->key_enc),
388 *(des_key_schedule *)sav->sched))
397 struct secasvar *sav,
405 *(des_key_schedule *)sav->sched, DES_DECRYPT);
412 struct secasvar *sav,
420 *(des_key_schedule *)sav->sched, DES_ENCRYPT);
425 esp_cbc_mature(sav)
426 struct secasvar *sav;
431 if (sav->flags & SADB_X_EXT_OLD) {
436 if (sav->flags & SADB_X_EXT_DERIV) {
442 if (!sav->key_enc) {
447 algo = esp_algorithm_lookup(sav->alg_enc);
454 keylen = sav->key_enc->sadb_key_bits;
458 algo->name, sav->key_enc->sadb_key_bits));
461 switch (sav->alg_enc) {
464 if (des_is_weak_key((des_cblock *)_KEYBUF(sav->key_enc)) ||
465 des_is_weak_key((des_cblock *)(_KEYBUF(sav->key_enc) + 8)) ||
466 des_is_weak_key((des_cblock *)(_KEYBUF(sav->key_enc) + 16))) {
502 struct secasvar *sav)
506 BF_set_key((BF_KEY *)sav->sched, _KEYLEN(sav->key_enc),
507 _KEYBUF(sav->key_enc));
514 struct secasvar *sav,
524 BF_decrypt(t, (BF_KEY *)sav->sched);
534 struct secasvar *sav,
544 BF_encrypt(t, (BF_KEY *)sav->sched);
562 struct secasvar *sav)
565 set_cast128_subkey((u_int32_t *)sav->sched, _KEYBUF(sav->key_enc),
566 _KEYLEN(sav->key_enc));
573 struct secasvar *sav,
578 if (_KEYLEN(sav->key_enc) <= 80 / 8)
579 cast128_decrypt_round12(d, s, (u_int32_t *)sav->sched);
581 cast128_decrypt_round16(d, s, (u_int32_t *)sav->sched);
588 struct secasvar *sav,
593 if (_KEYLEN(sav->key_enc) <= 80 / 8)
594 cast128_encrypt_round12(d, s, (u_int32_t *)sav->sched);
596 cast128_encrypt_round16(d, s, (u_int32_t *)sav->sched);
612 struct secasvar *sav)
620 p = (des_key_schedule *)sav->sched;
621 k = _KEYBUF(sav->key_enc);
633 struct secasvar *sav,
640 p = (des_key_schedule *)sav->sched;
650 struct secasvar *sav,
657 p = (des_key_schedule *)sav->sched;
667 __unused struct secasvar *sav)
676 esp_cbc_decrypt(m, off, sav, algo, ivlen)
679 struct secasvar *sav;
697 if (ivlen != sav->ivlen || ivlen > sizeof(iv)) {
716 if (sav->flags & SADB_X_EXT_OLD) {
723 if (sav->flags & SADB_X_EXT_DERIV) {
837 (*algo->blockdecrypt)(algo, sav, sp, mtod(d, u_int8_t *) + dn);
879 struct secasvar *sav,
897 if (ivlen != sav->ivlen || ivlen > sizeof(iv)) {
916 if (sav->flags & SADB_X_EXT_OLD) {
923 if (sav->flags & SADB_X_EXT_DERIV) {
943 bcopy(sav->iv, iv, ivlen);
1049 (*algo->blockencrypt)(algo, sav, sp, mtod(d, u_int8_t *) + dn);
1073 key_sa_stir_iv(sav);
1082 esp_auth(m0, skip, length, sav, sum)
1086 struct secasvar *sav;
1118 if (!sav) {
1123 algo = ah_algorithm_lookup(sav->alg_auth);
1127 sav->alg_auth));
1135 siz = (((*algo->sumsiz)(sav) + 3) & ~(4 - 1));
1158 error = (*algo->init)(&s, sav);