Don't include NID_undef in short/long name tables

NID_undef actually has names, but OBJ_sn2nid and OBJ_ln2nid's calling
convention cannot distinguish finding NID_undef from finding nothing.
Thus we may as well save 4 bytes by omitting this.

Change-Id: I6102e67141a2f5524aacf0ea84e6a2b2d2add534
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/63529
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
chromium-stable
David Benjamin 1 year ago committed by Boringssl LUCI CQ
parent 5e1496bf00
commit 8a062a7112
  1. 2
      crypto/obj/obj_dat.h
  2. 3
      crypto/obj/obj_test.cc
  3. 8
      crypto/obj/objects.go

@ -8980,7 +8980,6 @@ static const uint16_t kNIDsInShortNameOrder[] = {
16 /* ST */,
143 /* SXNetID */,
458 /* UID */,
0 /* UNDEF */,
948 /* X25519 */,
964 /* X25519Kyber768Draft00 */,
961 /* X448 */,
@ -10670,7 +10669,6 @@ static const uint16_t kNIDsInLongNameOrder[] = {
106 /* title */,
682 /* tpBasis */,
436 /* ucl */,
0 /* undefined */,
888 /* uniqueMember */,
55 /* unstructuredAddress */,
49 /* unstructuredName */,

@ -56,6 +56,9 @@ TEST(ObjTest, TestBasic) {
};
CBS_init(&cbs, kUnknownDER, sizeof(kUnknownDER));
ASSERT_EQ(NID_undef, OBJ_cbs2nid(&cbs));
EXPECT_EQ(NID_undef, OBJ_sn2nid("UNDEF"));
EXPECT_EQ(NID_undef, OBJ_ln2nid("undefined"));
}
TEST(ObjTest, TestSignatureAlgorithms) {

@ -640,8 +640,12 @@ func writeData(path string, objs *objects) error {
fmt.Fprintf(&b, "\nstatic const uint16_t kNIDsInShortNameOrder[] = {\n")
for _, nid := range nids {
// Including NID_undef in the table does not do anything. Whether OBJ_sn2nid
// finds the object or not, it will return NID_undef.
if nid != 0 {
fmt.Fprintf(&b, "%d /* %s */,\n", nid, objs.byNID[nid].shortName)
}
}
fmt.Fprintf(&b, "};\n")
// Emit a list of NIDs sorted by long name.
@ -656,8 +660,12 @@ func writeData(path string, objs *objects) error {
fmt.Fprintf(&b, "\nstatic const uint16_t kNIDsInLongNameOrder[] = {\n")
for _, nid := range nids {
// Including NID_undef in the table does not do anything. Whether OBJ_ln2nid
// finds the object or not, it will return NID_undef.
if nid != 0 {
fmt.Fprintf(&b, "%d /* %s */,\n", nid, objs.byNID[nid].longName)
}
}
fmt.Fprintf(&b, "};\n")
// Emit a list of NIDs sorted by OID.

Loading…
Cancel
Save