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

Function swcr_setup_ccm

freebsd/opencrypto/cryptosoft.c:1130–1172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1128}
1129
1130static int
1131swcr_setup_ccm(struct swcr_session *ses,
1132 const struct crypto_session_params *csp)
1133{
1134 struct swcr_auth *swa;
1135 struct auth_hash *axf;
1136
1137 if (csp->csp_ivlen != AES_CCM_IV_LEN)
1138 return (EINVAL);
1139
1140 /* First, setup the auth side. */
1141 swa = &ses->swcr_auth;
1142 switch (csp->csp_cipher_klen * 8) {
1143 case 128:
1144 axf = &auth_hash_ccm_cbc_mac_128;
1145 break;
1146 case 192:
1147 axf = &auth_hash_ccm_cbc_mac_192;
1148 break;
1149 case 256:
1150 axf = &auth_hash_ccm_cbc_mac_256;
1151 break;
1152 default:
1153 return (EINVAL);
1154 }
1155 swa->sw_axf = axf;
1156 if (csp->csp_auth_mlen < 0 || csp->csp_auth_mlen > axf->hashsize)
1157 return (EINVAL);
1158 if (csp->csp_auth_mlen == 0)
1159 swa->sw_mlen = axf->hashsize;
1160 else
1161 swa->sw_mlen = csp->csp_auth_mlen;
1162 swa->sw_ictx = malloc(axf->ctxsize, M_CRYPTO_DATA, M_NOWAIT);
1163 if (swa->sw_ictx == NULL)
1164 return (ENOBUFS);
1165 axf->Init(swa->sw_ictx);
1166 if (csp->csp_cipher_key != NULL)
1167 axf->Setkey(swa->sw_ictx, csp->csp_cipher_key,
1168 csp->csp_cipher_klen);
1169
1170 /* Second, setup the cipher side. */
1171 return (swcr_setup_cipher(ses, csp));
1172}
1173
1174static bool
1175swcr_auth_supported(const struct crypto_session_params *csp)

Callers 1

swcr_newsessionFunction · 0.85

Calls 3

mallocFunction · 0.85
swcr_setup_cipherFunction · 0.85
InitMethod · 0.80

Tested by

no test coverage detected