@@ -653,47 +653,6 @@ static enum aws_libcrypto_version s_resolve_libcrypto_sharedlib(void) {
653653 return AWS_LIBCRYPTO_NONE ;
654654}
655655
656- /* Validate at runtime that we're linked against the same libcrypto we compiled against. */
657- static void s_validate_libcrypto_linkage (void ) {
658- /* NOTE: the choice of stack buffer size is somewhat arbitrary. it's
659- * possible, but unlikely, that libcrypto version strings may exceed this in
660- * the future. we guard against buffer overflow by limiting write size in
661- * snprintf with the size of the buffer itself. if libcrypto version strings
662- * do eventually exceed the chosen size, this runtime check will fail and
663- * will need to be addressed by increasing buffer size.*/
664- char expected_version [64 ] = {0 };
665- #if defined(OPENSSL_IS_AWSLC )
666- /* get FIPS mode at runtime because headers don't give any indication of
667- * AWS-LC's FIPSness at aws-c-cal compile time. version number can still be
668- * captured at preprocess/compile time from AWSLC_VERSION_NUMBER_STRING.*/
669- const char * mode = FIPS_mode () ? "AWS-LC FIPS" : "AWS-LC" ;
670- snprintf (expected_version , sizeof (expected_version ), "%s %s" , mode , AWSLC_VERSION_NUMBER_STRING );
671- #elif defined(OPENSSL_IS_BORINGSSL )
672- snprintf (expected_version , sizeof (expected_version ), "BoringSSL" );
673- #elif defined(OPENSSL_IS_OPENSSL )
674- snprintf (expected_version , sizeof (expected_version ), OPENSSL_VERSION_TEXT );
675- #elif !defined(BYO_CRYPTO )
676- # error Unsupported libcrypto!
677- #endif
678- const char * runtime_version = SSLeay_version (SSLEAY_VERSION );
679- AWS_LOGF_DEBUG (
680- AWS_LS_CAL_LIBCRYPTO_RESOLVE ,
681- "Compiled with libcrypto %s, linked to libcrypto %s" ,
682- expected_version ,
683- runtime_version );
684- #if defined(OPENSSL_IS_OPENSSL )
685- /* Validate that the string "AWS-LC" doesn't appear in OpenSSL version str. */
686- AWS_FATAL_ASSERT (strstr ("AWS-LC" , expected_version ) == NULL );
687- AWS_FATAL_ASSERT (strstr ("AWS-LC" , runtime_version ) == NULL );
688- /* Validate both expected and runtime versions begin with OpenSSL's version str prefix. */
689- const char * openssl_prefix = "OpenSSL " ;
690- AWS_FATAL_ASSERT (strncmp (openssl_prefix , expected_version , strlen (openssl_prefix )) == 0 );
691- AWS_FATAL_ASSERT (strncmp (openssl_prefix , runtime_version , strlen (openssl_prefix )) == 0 );
692- #else
693- AWS_FATAL_ASSERT (strcmp (expected_version , runtime_version ) == 0 && "libcrypto mislink" );
694- #endif
695- }
696-
697656static enum aws_libcrypto_version s_resolve_libcrypto (void ) {
698657 /* Try to auto-resolve against what's linked in/process space */
699658 AWS_LOGF_DEBUG (AWS_LS_CAL_LIBCRYPTO_RESOLVE , "searching process and loaded modules" );
@@ -719,7 +678,7 @@ static enum aws_libcrypto_version s_resolve_libcrypto(void) {
719678 result = s_resolve_libcrypto_sharedlib ();
720679 }
721680
722- s_validate_libcrypto_linkage ();
681+ aws_validate_libcrypto_linkage ();
723682
724683 return result ;
725684}
0 commit comments