1616
1717# define SUPPORT_AES_GCM_VIA_SPI 1
1818# include "common_cryptor_spi.h"
19-
20- # if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED ) && (__MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 /* macOS 10.13 */ )) || \
21- (defined(__IPHONE_OS_VERSION_MAX_ALLOWED ) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* iOS v11 */ ))
22- # define USE_LATEST_CRYPTO_API 1
23- # endif
2419#endif
2520
2621struct cc_aes_cipher {
@@ -370,45 +365,6 @@ static int s_gcm_decrypt(struct aws_symmetric_cipher *cipher, struct aws_byte_cu
370365
371366#ifdef SUPPORT_AES_GCM_VIA_SPI
372367
373- /*
374- * Note that CCCryptorGCMFinal is deprecated in Mac 10.13. It also doesn't compare the tag with expected tag
375- * https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60118.1.1/include/CommonCryptorSPI.h.auto.html
376- */
377- static CCStatus s_cc_crypto_gcm_finalize (struct _CCCryptor * encryptor_handle , uint8_t * buffer , size_t tag_length ) {
378- # ifdef USE_LATEST_CRYPTO_API
379- if (__builtin_available (macOS 10.13 , iOS 11.0 , * )) {
380- return CCCryptorGCMFinalize (encryptor_handle , buffer , tag_length );
381- } else {
382- /* We would never hit this branch for newer macOS and iOS versions because of the __builtin_available check, so we can
383- * suppress the compiler warning. */
384- # pragma clang diagnostic push
385- # pragma clang diagnostic ignored "-Wdeprecated-declarations"
386- return CCCryptorGCMFinal (encryptor_handle , buffer , & tag_length );
387- # pragma clang diagnostic pop
388- }
389- # else
390- return CCCryptorGCMFinal (encryptor_handle , buffer , & tag_length );
391-
392- # endif
393- }
394-
395- static CCCryptorStatus s_cc_cryptor_gcm_set_iv (struct _CCCryptor * encryptor_handle , uint8_t * buffer , size_t length ) {
396- # ifdef USE_LATEST_CRYPTO_API
397- if (__builtin_available (macOS 10.13 , iOS 11.0 , * )) {
398- return CCCryptorGCMSetIV (encryptor_handle , buffer , length );
399- } else {
400- /* We would never hit this branch for newer macOS and iOS versions because of the __builtin_available check, so we can
401- * suppress the compiler warning. */
402- # pragma clang diagnostic push
403- # pragma clang diagnostic ignored "-Wdeprecated-declarations"
404- return CCCryptorGCMAddIV (encryptor_handle , buffer , length );
405- # pragma clang diagnostic pop
406- }
407- # else
408- return CCCryptorGCMAddIV (encryptor_handle , buffer , length );
409- # endif
410- }
411-
412368static int s_finalize_gcm_encryption (struct aws_symmetric_cipher * cipher , struct aws_byte_buf * out ) {
413369 (void )out ;
414370
@@ -420,7 +376,7 @@ static int s_finalize_gcm_encryption(struct aws_symmetric_cipher *cipher, struct
420376 struct cc_aes_cipher * cc_cipher = cipher -> impl ;
421377
422378 size_t tag_length = AWS_AES_256_CIPHER_BLOCK_SIZE ;
423- CCStatus status = s_cc_crypto_gcm_finalize (cc_cipher -> encryptor_handle , cipher -> tag .buffer , tag_length );
379+ CCStatus status = CCCryptorGCMFinalize (cc_cipher -> encryptor_handle , cipher -> tag .buffer , tag_length );
424380 if (status != kCCSuccess ) {
425381 cipher -> state = AWS_SYMMETRIC_CIPHER_ERROR ;
426382 return aws_raise_error (AWS_ERROR_INVALID_ARGUMENT );
@@ -436,7 +392,7 @@ static int s_finalize_gcm_decryption(struct aws_symmetric_cipher *cipher, struct
436392 struct cc_aes_cipher * cc_cipher = cipher -> impl ;
437393
438394 size_t tag_length = AWS_AES_256_CIPHER_BLOCK_SIZE ;
439- CCStatus status = s_cc_crypto_gcm_finalize (cc_cipher -> decryptor_handle , cipher -> tag .buffer , tag_length );
395+ CCStatus status = CCCryptorGCMFinalize (cc_cipher -> decryptor_handle , cipher -> tag .buffer , tag_length );
440396 if (status != kCCSuccess ) {
441397 cipher -> state = AWS_SYMMETRIC_CIPHER_ERROR ;
442398 return aws_raise_error (AWS_ERROR_INVALID_ARGUMENT );
@@ -495,8 +451,8 @@ static int s_initialize_gcm_cipher_materials(
495451 if (status != kCCSuccess ) {
496452 return aws_raise_error (AWS_ERROR_INVALID_ARGUMENT );
497453 }
498- status = s_cc_cryptor_gcm_set_iv (
499- cc_cipher -> encryptor_handle , cc_cipher -> cipher_base .iv .buffer , cc_cipher -> cipher_base .iv .len );
454+ status =
455+ CCCryptorGCMSetIV ( cc_cipher -> encryptor_handle , cc_cipher -> cipher_base .iv .buffer , cc_cipher -> cipher_base .iv .len );
500456
501457 if (status != kCCSuccess ) {
502458 return aws_raise_error (AWS_ERROR_INVALID_ARGUMENT );
@@ -528,8 +484,8 @@ static int s_initialize_gcm_cipher_materials(
528484 if (status != kCCSuccess ) {
529485 return aws_raise_error (AWS_ERROR_INVALID_ARGUMENT );
530486 }
531- status = s_cc_cryptor_gcm_set_iv (
532- cc_cipher -> decryptor_handle , cc_cipher -> cipher_base .iv .buffer , cc_cipher -> cipher_base .iv .len );
487+ status =
488+ CCCryptorGCMSetIV ( cc_cipher -> decryptor_handle , cc_cipher -> cipher_base .iv .buffer , cc_cipher -> cipher_base .iv .len );
533489
534490 if (status != kCCSuccess ) {
535491 return aws_raise_error (AWS_ERROR_INVALID_ARGUMENT );
0 commit comments