Lines Matching refs:transform
187 bool GenerateKey(string transform, int keySize, bool sign = false) { in GenerateKey() argument
188 if (transform == key_transform_) { in GenerateKey()
196 optional<Algorithm> algorithm = getAlgorithm(transform); in GenerateKey()
198 cerr << "Error: invalid algorithm " << transform << endl; in GenerateKey()
201 key_transform_ = transform; in GenerateKey()
202 return GenerateKey(*algorithm, keySize, getDigest(transform), getPadding(transform, sign), in GenerateKey()
203 getBlockMode(transform)); in GenerateKey()
212 AuthorizationSet getOperationParams(string transform, bool sign = false) { in getOperationParams() argument
214 .Padding(getPadding(transform, sign)) in getOperationParams()
216 .Digest(getDigest(transform)); in getOperationParams()
217 optional<BlockMode> blockMode = getBlockMode(transform); in getOperationParams()
329 optional<BlockMode> getBlockMode(string transform) { in getBlockMode() argument
330 if (transform.find("/ECB") != string::npos) { in getBlockMode()
332 } else if (transform.find("/CBC") != string::npos) { in getBlockMode()
334 } else if (transform.find("/CTR") != string::npos) { in getBlockMode()
336 } else if (transform.find("/GCM") != string::npos) { in getBlockMode()
342 PaddingMode getPadding(string transform, bool sign) { in getPadding() argument
343 if (transform.find("/PKCS7") != string::npos) { in getPadding()
345 } else if (transform.find("/PSS") != string::npos) { in getPadding()
347 } else if (transform.find("/OAEP") != string::npos) { in getPadding()
349 } else if (transform.find("/PKCS1") != string::npos) { in getPadding()
351 } else if (sign && transform.find("RSA") != string::npos) { in getPadding()
358 optional<Algorithm> getAlgorithm(string transform) { in getAlgorithm() argument
359 if (transform.find("AES") != string::npos) { in getAlgorithm()
361 } else if (transform.find("Hmac") != string::npos) { in getAlgorithm()
363 } else if (transform.find("DESede") != string::npos) { in getAlgorithm()
365 } else if (transform.find("RSA") != string::npos) { in getAlgorithm()
367 } else if (transform.find("EC") != string::npos) { in getAlgorithm()
370 cerr << "Can't find algorithm for " << transform << endl; in getAlgorithm()
374 Digest getDigest(string transform) { in getDigest() argument
375 if (transform.find("MD5") != string::npos) { in getDigest()
377 } else if (transform.find("SHA1") != string::npos || in getDigest()
378 transform.find("SHA-1") != string::npos) { in getDigest()
380 } else if (transform.find("SHA224") != string::npos) { in getDigest()
382 } else if (transform.find("SHA256") != string::npos) { in getDigest()
384 } else if (transform.find("SHA384") != string::npos) { in getDigest()
386 } else if (transform.find("SHA512") != string::npos) { in getDigest()
388 } else if (transform.find("RSA") != string::npos && in getDigest()
389 transform.find("OAEP") != string::npos) { in getDigest()
419 #define BENCHMARK_KM(func, transform, keySize) \ argument
420 BENCHMARK_CAPTURE(func, transform/keySize, #transform "/" #keySize, keySize)->Apply(settings);
421 #define BENCHMARK_KM_MSG(func, transform, keySize, msgSize) \ argument
422 BENCHMARK_CAPTURE(func, transform/keySize/msgSize, #transform "/" #keySize "/" #msgSize, \
426 #define BENCHMARK_KM_ALL_MSGS(func, transform, keySize) \ argument
427 BENCHMARK_KM_MSG(func, transform, keySize, SMALL_MESSAGE_SIZE) \
428 BENCHMARK_KM_MSG(func, transform, keySize, MEDIUM_MESSAGE_SIZE) \
429 BENCHMARK_KM_MSG(func, transform, keySize, LARGE_MESSAGE_SIZE)
431 #define BENCHMARK_KM_CIPHER(transform, keySize, msgSize) \ argument
432 BENCHMARK_KM_MSG(encrypt, transform, keySize, msgSize) \
433 BENCHMARK_KM_MSG(decrypt, transform, keySize, msgSize)
435 #define BENCHMARK_KM_CIPHER_ALL_MSGS(transform, keySize) \ argument
436 BENCHMARK_KM_ALL_MSGS(encrypt, transform, keySize) \
437 BENCHMARK_KM_ALL_MSGS(decrypt, transform, keySize)
439 #define BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, keySize) \ argument
440 BENCHMARK_KM_ALL_MSGS(sign, transform, keySize) \
441 BENCHMARK_KM_ALL_MSGS(verify, transform, keySize)
447 static void keygen(benchmark::State& state, string transform, int keySize) { in keygen() argument
450 keymaster->GenerateKey(transform, keySize); in keygen()
484 static void sign(benchmark::State& state, string transform, int keySize, int msgSize) { in sign() argument
486 if (!keymaster->GenerateKey(transform, keySize, true)) { in sign()
491 auto params = keymaster->getOperationParams(transform, true); in sign()
510 static void verify(benchmark::State& state, string transform, int keySize, int msgSize) { in verify() argument
512 if (!keymaster->GenerateKey(transform, keySize, true)) { in verify()
518 AuthorizationSet in_params = keymaster->getOperationParams(transform, true); in verify()
550 #define BENCHMARK_KM_SIGNATURE_ALL_HMAC_KEYS(transform) \ argument
551 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 64) \
552 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 128) \
553 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 256) \
554 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 512) \
555 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 1024) \
556 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 2024) \
557 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 4096) \
558 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 8192)
567 #define BENCHMARK_KM_SIGNATURE_ALL_ECDSA_KEYS(transform) \ argument
568 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 224) \
569 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 256) \
570 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 384) \
571 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 521)
580 #define BENCHMARK_KM_SIGNATURE_ALL_RSA_KEYS(transform) \ argument
581 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 2048) \
582 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 3072) \
583 BENCHMARK_KM_SIGNATURE_ALL_MSGS(transform, 4096)
602 static void encrypt(benchmark::State& state, string transform, int keySize, int msgSize) { in encrypt() argument
604 if (!keymaster->GenerateKey(transform, keySize)) { in encrypt()
609 auto params = keymaster->getOperationParams(transform); in encrypt()
629 static void decrypt(benchmark::State& state, string transform, int keySize, int msgSize) { in decrypt() argument
631 if (!keymaster->GenerateKey(transform, keySize)) { in decrypt()
637 AuthorizationSet in_params = keymaster->getOperationParams(transform); in decrypt()
670 #define BENCHMARK_KM_CIPHER_ALL_AES_KEYS(transform) \ argument
671 BENCHMARK_KM_CIPHER_ALL_MSGS(transform, 128) \
672 BENCHMARK_KM_CIPHER_ALL_MSGS(transform, 256)
687 #define BENCHMARK_KM_CIPHER_ALL_RSA_KEYS(transform, msgSize) \ argument
688 BENCHMARK_KM_CIPHER(transform, 2048, msgSize) \
689 BENCHMARK_KM_CIPHER(transform, 3072, msgSize) \
690 BENCHMARK_KM_CIPHER(transform, 4096, msgSize)