@@ -920,76 +920,3 @@ int test_wc_DecodeRsaPssParams(void)
920920#endif /* WC_RSA_PSS && !NO_RSA && !NO_ASN */
921921 return EXPECT_RESULT ();
922922}
923-
924- int test_wc_DecodeObjectId (void )
925- {
926- EXPECT_DECLS ;
927-
928- #if defined(HAVE_OID_DECODING ) || defined(WOLFSSL_ASN_PRINT )
929- {
930- /* OID 1.2.840.113549.1.1.11 (sha256WithRSAEncryption)
931- * DER encoding: 2a 86 48 86 f7 0d 01 01 0b
932- * First byte 0x2a = 42 => arc0 = 42/40 = 1, arc1 = 42%40 = 2
933- * Remaining arcs: 840, 113549, 1, 1, 11
934- */
935- static const byte oid_sha256rsa [] = {
936- 0x2a , 0x86 , 0x48 , 0x86 , 0xf7 , 0x0d , 0x01 , 0x01 , 0x0b
937- };
938- word16 out [MAX_OID_SZ ];
939- word32 outSz ;
940-
941- /* Test 1: Normal decode */
942- outSz = MAX_OID_SZ ;
943- ExpectIntEQ (DecodeObjectId (oid_sha256rsa , sizeof (oid_sha256rsa ),
944- out , & outSz ), 0 );
945- ExpectIntEQ ((int )outSz , 7 );
946- ExpectIntEQ (out [0 ], 1 );
947- ExpectIntEQ (out [1 ], 2 );
948- ExpectIntEQ (out [2 ], 840 );
949- ExpectIntEQ (out [3 ], (word16 )113549 ); /* truncated to word16 */
950- ExpectIntEQ (out [4 ], 1 );
951- ExpectIntEQ (out [5 ], 1 );
952- ExpectIntEQ (out [6 ], 11 );
953-
954- /* Test 2: NULL args */
955- outSz = MAX_OID_SZ ;
956- ExpectIntEQ (DecodeObjectId (NULL , sizeof (oid_sha256rsa ), out , & outSz ),
957- WC_NO_ERR_TRACE (BAD_FUNC_ARG ));
958- ExpectIntEQ (DecodeObjectId (oid_sha256rsa , sizeof (oid_sha256rsa ),
959- out , NULL ),
960- WC_NO_ERR_TRACE (BAD_FUNC_ARG ));
961-
962- /* Test 3 (Bug 1): outSz=1 must return BUFFER_E, not OOB write.
963- * The first OID byte decodes into two arcs, so outSz must be >= 2. */
964- outSz = 1 ;
965- ExpectIntEQ (DecodeObjectId (oid_sha256rsa , sizeof (oid_sha256rsa ),
966- out , & outSz ),
967- WC_NO_ERR_TRACE (BUFFER_E ));
968-
969- /* Test 4: outSz=0 must also return BUFFER_E */
970- outSz = 0 ;
971- ExpectIntEQ (DecodeObjectId (oid_sha256rsa , sizeof (oid_sha256rsa ),
972- out , & outSz ),
973- WC_NO_ERR_TRACE (BUFFER_E ));
974-
975- /* Test 5: outSz=2 is enough for a single-byte OID (two arcs) */
976- {
977- static const byte oid_one_byte [] = { 0x2a }; /* 1.2 */
978- outSz = 2 ;
979- ExpectIntEQ (DecodeObjectId (oid_one_byte , sizeof (oid_one_byte ),
980- out , & outSz ), 0 );
981- ExpectIntEQ ((int )outSz , 2 );
982- ExpectIntEQ (out [0 ], 1 );
983- ExpectIntEQ (out [1 ], 2 );
984- }
985-
986- /* Test 6: Buffer too small for later arcs */
987- outSz = 3 ; /* only room for 3 arcs, but OID has 7 */
988- ExpectIntEQ (DecodeObjectId (oid_sha256rsa , sizeof (oid_sha256rsa ),
989- out , & outSz ),
990- WC_NO_ERR_TRACE (BUFFER_E ));
991- }
992- #endif /* HAVE_OID_DECODING || WOLFSSL_ASN_PRINT */
993-
994- return EXPECT_RESULT ();
995- }
0 commit comments