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

Function swcr_probesession

freebsd/opencrypto/cryptosoft.c:1243–1303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1241#define SUPPORTED_SES (CSP_F_SEPARATE_OUTPUT | CSP_F_SEPARATE_AAD | CSP_F_ESN)
1242
1243static int
1244swcr_probesession(device_t dev, const struct crypto_session_params *csp)
1245{
1246 if ((csp->csp_flags & ~(SUPPORTED_SES)) != 0)
1247 return (EINVAL);
1248 switch (csp->csp_mode) {
1249 case CSP_MODE_COMPRESS:
1250 switch (csp->csp_cipher_alg) {
1251 case CRYPTO_DEFLATE_COMP:
1252 break;
1253 default:
1254 return (EINVAL);
1255 }
1256 break;
1257 case CSP_MODE_CIPHER:
1258 switch (csp->csp_cipher_alg) {
1259 case CRYPTO_AES_NIST_GCM_16:
1260 case CRYPTO_AES_CCM_16:
1261 return (EINVAL);
1262 default:
1263 if (!swcr_cipher_supported(csp))
1264 return (EINVAL);
1265 break;
1266 }
1267 break;
1268 case CSP_MODE_DIGEST:
1269 if (!swcr_auth_supported(csp))
1270 return (EINVAL);
1271 break;
1272 case CSP_MODE_AEAD:
1273 switch (csp->csp_cipher_alg) {
1274 case CRYPTO_AES_NIST_GCM_16:
1275 case CRYPTO_AES_CCM_16:
1276 break;
1277 default:
1278 return (EINVAL);
1279 }
1280 break;
1281 case CSP_MODE_ETA:
1282 /* AEAD algorithms cannot be used for EtA. */
1283 switch (csp->csp_cipher_alg) {
1284 case CRYPTO_AES_NIST_GCM_16:
1285 case CRYPTO_AES_CCM_16:
1286 return (EINVAL);
1287 }
1288 switch (csp->csp_auth_alg) {
1289 case CRYPTO_AES_NIST_GMAC:
1290 case CRYPTO_AES_CCM_CBC_MAC:
1291 return (EINVAL);
1292 }
1293
1294 if (!swcr_cipher_supported(csp) ||
1295 !swcr_auth_supported(csp))
1296 return (EINVAL);
1297 break;
1298 default:
1299 return (EINVAL);
1300 }

Callers

nothing calls this directly

Calls 2

swcr_cipher_supportedFunction · 0.85
swcr_auth_supportedFunction · 0.85

Tested by

no test coverage detected