Skip to content

Commit

Permalink
rsa test update
Browse files Browse the repository at this point in the history
  • Loading branch information
ecdeye committed Jul 25, 2024
1 parent 7f9951f commit 3bc1c7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tool-openssl/rsa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ bool rsaTool(const args_list_t &args) {
*p = toupper(*p);
}
if (out_file) {
fprintf(out_file.get(), "Modulus=%s\r\n", hex_modulus);
fprintf(out_file.get(), "Modulus=%s\n", hex_modulus);
} else {
printf("Modulus=%s\r\n", hex_modulus);
printf("Modulus=%s\n", hex_modulus);
}
OPENSSL_free(hex_modulus);
}
Expand Down
12 changes: 5 additions & 7 deletions tool-openssl/rsa_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,8 @@ std::string ReadFileToString(const std::string& file_path) {
return buffer.str();
}

// OpenSSL rsa boundaries
const std::string BEGIN = "-----BEGIN PRIVATE KEY-----";
const std::string END = "-----END PRIVATE KEY-----";
// AWS-LC rsa boundaries

// RSA boundaries
const std::string RSA_BEGIN = "-----BEGIN RSA PRIVATE KEY-----";
const std::string RSA_END = "-----END RSA PRIVATE KEY-----";

Expand All @@ -228,8 +226,8 @@ TEST_F(RSAComparisonTest, RSAToolCompareModulusOpenSSL) {
ASSERT_EQ(tool_output_str.compare(tool_output_str.size() - RSA_END.size(), RSA_END.size(), RSA_END), 0);

trim(openssl_output_str);
ASSERT_EQ(openssl_output_str.compare(0, BEGIN.size(), BEGIN), 0);
ASSERT_EQ(openssl_output_str.compare(openssl_output_str.size() - END.size(), END.size(), END), 0);
ASSERT_EQ(openssl_output_str.compare(0, RSA_BEGIN.size(), RSA_BEGIN), 0);
ASSERT_EQ(openssl_output_str.compare(openssl_output_str.size() - RSA_END.size(), RSA_END.size(), RSA_END), 0);
}

// Test against OpenSSL output "openssl rsa -in file -modulus -noout"
Expand Down Expand Up @@ -264,7 +262,7 @@ TEST_F(RSAComparisonTest, RSAToolCompareModulusOutOpenSSL) {

trim(openssl_output_str);
ASSERT_EQ(openssl_output_str.compare(0, MODULUS.size(), MODULUS), 0);
ASSERT_EQ(openssl_output_str.compare(openssl_output_str.size() - END.size(), END.size(), END), 0);
ASSERT_EQ(openssl_output_str.compare(openssl_output_str.size() - RSA_END.size(), RSA_END.size(), RSA_END), 0);
}

// Test against OpenSSL output "openssl rsa -in file -modulus -out out_file -noout"
Expand Down

0 comments on commit 3bc1c7d

Please sign in to comment.