safe.c (c03414326909ed7a740be3ba63fbbef01fe513a8) safe.c (29fe41ddd714bae92a09fd4098fad614945bedf5)
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2003 Sam Leffler, Errno Consulting
5 * Copyright (c) 2003 Global Technology Associates, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 880 unchanged lines hidden (view full) ---

889 * Setup encrypt/decrypt state. When using basic ops
890 * we can't use an inline IV because hash/crypt offset
891 * must be from the end of the IV to the start of the
892 * crypt data and this leaves out the preceding header
893 * from the hash calculation. Instead we place the IV
894 * in the state record and set the hash/crypt offset to
895 * copy both the header+IV.
896 */
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2003 Sam Leffler, Errno Consulting
5 * Copyright (c) 2003 Global Technology Associates, Inc.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 880 unchanged lines hidden (view full) ---

889 * Setup encrypt/decrypt state. When using basic ops
890 * we can't use an inline IV because hash/crypt offset
891 * must be from the end of the IV to the start of the
892 * crypt data and this leaves out the preceding header
893 * from the hash calculation. Instead we place the IV
894 * in the state record and set the hash/crypt offset to
895 * copy both the header+IV.
896 */
897 if (crp->crp_flags & CRYPTO_F_IV_GENERATE) {
898 arc4rand(re->re_sastate.sa_saved_iv, csp->csp_ivlen, 0);
899 crypto_copyback(crp, crp->crp_iv_start, csp->csp_ivlen,
900 re->re_sastate.sa_saved_iv);
901 } else if (crp->crp_flags & CRYPTO_F_IV_SEPARATE)
902 memcpy(re->re_sastate.sa_saved_iv, crp->crp_iv,
903 csp->csp_ivlen);
904 else
905 crypto_copydata(crp, crp->crp_iv_start, csp->csp_ivlen,
906 re->re_sastate.sa_saved_iv);
897 crypto_read_iv(crp, re->re_sastate.sa_saved_iv);
907 cmd0 |= SAFE_SA_CMD0_IVLD_STATE;
908
909 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) {
910 cmd0 |= SAFE_SA_CMD0_OUTBOUND;
911
912 /*
913 * XXX: I suspect we don't need this since we
914 * don't save the returned IV.

--- 1132 unchanged lines hidden ---
898 cmd0 |= SAFE_SA_CMD0_IVLD_STATE;
899
900 if (CRYPTO_OP_IS_ENCRYPT(crp->crp_op)) {
901 cmd0 |= SAFE_SA_CMD0_OUTBOUND;
902
903 /*
904 * XXX: I suspect we don't need this since we
905 * don't save the returned IV.

--- 1132 unchanged lines hidden ---