15 #include <gtest/gtest.h> 
   22 #include "../internal.h" 
   27   static const char kShortName[] = 
"RSA-SHA256";
 
   28   static const char kLongName[] = 
"sha256WithRSAEncryption";
 
   29   static const char kText[] = 
"1.2.840.113549.1.1.11";
 
   31       0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
 
   54   static const uint8_t kUnknownDER[] = {
 
   55       0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x04, 0x01, 0x84, 0xb7, 0x09, 0x02,
 
   61 TEST(ObjTest, TestSignatureAlgorithms) {
 
   62   int digest_nid, pkey_nid;
 
   77                           bool always_return_oid, 
const char *expected) {
 
   78   bssl::UniquePtr<ASN1_OBJECT> 
obj(
 
   85   int expected_len = 
static_cast<int>(strlen(expected));
 
   88   if (
len != expected_len) {
 
   90             "OBJ_obj2txt of %s with out_len = 0 returned %d, wanted %d.\n",
 
   91             expected, 
len, expected_len);
 
   98   if (
len != expected_len) {
 
  100             "OBJ_obj2txt of %s with out_len = 1 returned %d, wanted %d.\n",
 
  101             expected, 
len, expected_len);
 
  105   if (
OPENSSL_memchr(short_buf, 
'\0', 
sizeof(short_buf)) == 
nullptr) {
 
  107             "OBJ_obj2txt of %s with out_len = 1 did not NUL-terminate the " 
  115   if (
len != expected_len) {
 
  117             "OBJ_obj2txt of %s with out_len = 256 returned %d, wanted %d.\n",
 
  118             expected, 
len, expected_len);
 
  122   if (strcmp(
buf, expected) != 0) {
 
  123     fprintf(
stderr, 
"OBJ_obj2txt returned \"%s\"; wanted \"%s\".\n", 
buf,
 
  134   static const uint8_t kSHA256WithRSAEncryption[] = {
 
  135       0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
 
  140   static const uint8_t kBasicConstraints[] = {
 
  146   static const uint8_t kTestOID[] = {
 
  147       0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x04, 0x01, 0x84, 0xb7, 0x09, 0x00,
 
  151       ExpectObj2Txt(kSHA256WithRSAEncryption, 
sizeof(kSHA256WithRSAEncryption),
 
  152                     true , 
"1.2.840.113549.1.1.11"));
 
  154       ExpectObj2Txt(kSHA256WithRSAEncryption, 
sizeof(kSHA256WithRSAEncryption),
 
  155                     false , 
"sha256WithRSAEncryption"));
 
  157                             true , 
"2.5.29.19"));
 
  160                             "X509v3 Basic Constraints"));
 
  163                             "1.2.840.113554.4.1.72585.0"));
 
  165                             "1.2.840.113554.4.1.72585.0"));
 
  173   static const uint8_t kNonMinimalOID[] = {0x55, 0x1d, 0x80, 0x13};
 
  174   bssl::UniquePtr<ASN1_OBJECT> 
obj(
 
  182   static const uint8_t kOverflowOID[] = {
 
  183       0x2a, 0x86, 0x48, 0x86, 0xf7, 0x12, 0x04, 0x01, 0x84, 0xb7, 0x09,
 
  184       0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
 
  193   static const uint8_t kInvalidOID[] = {0x55, 0x1d, 0x93};