@@ -23718,7 +23718,11 @@ static int test_wc_Ed25519PublicKeyToDer(void)
2371823718 ExpectIntEQ(wc_ed25519_init(&key), 0);
2371923719 ExpectIntEQ(wc_InitRng(&rng), 0);
2372023720 ExpectIntEQ(wc_ed25519_make_key(&rng, ED25519_KEY_SIZE, &key), 0);
23721- ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, derBuf, 1024, 1), 0);
23721+ /* length only */
23722+ ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, NULL, 0, 0), 0);
23723+ ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, NULL, 0, 1), 0);
23724+ ExpectIntGT(wc_Ed25519PublicKeyToDer(&key, derBuf,
23725+ (word32)sizeof(derBuf), 1), 0);
2372223726
2372323727 DoExpectIntEQ(wc_FreeRng(&rng), 0);
2372423728 wc_ed25519_free(&key);
@@ -24611,8 +24615,11 @@ static int test_wc_Ed448PublicKeyToDer(void)
2461124615 ExpectIntEQ(wc_ed448_init(&key), 0);
2461224616 ExpectIntEQ(wc_InitRng(&rng), 0);
2461324617 ExpectIntEQ(wc_ed448_make_key(&rng, ED448_KEY_SIZE, &key), 0);
24614-
24615- ExpectIntGT(wc_Ed448PublicKeyToDer(&key, derBuf, 1024, 1), 0);
24618+ /* length only */
24619+ ExpectIntGT(wc_Ed448PublicKeyToDer(&key, NULL, 0, 0), 0);
24620+ ExpectIntGT(wc_Ed448PublicKeyToDer(&key, NULL, 0, 1), 0);
24621+ ExpectIntGT(wc_Ed448PublicKeyToDer(&key, derBuf,
24622+ (word32)sizeof(derBuf), 1), 0);
2461624623
2461724624 DoExpectIntEQ(wc_FreeRng(&rng), 0);
2461824625 wc_ed448_free(&key);
@@ -27238,9 +27245,10 @@ static int test_wc_Ed25519KeyToDer(void)
2723827245 /* Bad Cases */
2723927246 ExpectIntEQ(wc_Ed25519KeyToDer(NULL, NULL, 0), BAD_FUNC_ARG);
2724027247 ExpectIntEQ(wc_Ed25519KeyToDer(NULL, output, inLen), BAD_FUNC_ARG);
27241- ExpectIntEQ(wc_Ed25519KeyToDer(&ed25519Key, output, 0), BAD_FUNC_ARG );
27248+ ExpectIntEQ(wc_Ed25519KeyToDer(&ed25519Key, output, 0), BUFFER_E );
2724227249 /* Good Cases */
2724327250 /* length only */
27251+ ExpectIntGT(wc_Ed25519KeyToDer(&ed25519Key, NULL, 0), 0);
2724427252 ExpectIntGT(wc_Ed25519KeyToDer(&ed25519Key, NULL, inLen), 0);
2724527253 ExpectIntGT(wc_Ed25519KeyToDer(&ed25519Key, output, inLen), 0);
2724627254
@@ -27276,10 +27284,10 @@ static int test_wc_Ed25519PrivateKeyToDer(void)
2727627284 ExpectIntEQ(wc_Ed25519PrivateKeyToDer(NULL, NULL, 0), BAD_FUNC_ARG);
2727727285 ExpectIntEQ(wc_Ed25519PrivateKeyToDer(NULL, output, inLen), BAD_FUNC_ARG);
2727827286 ExpectIntEQ(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, output, 0),
27279- BAD_FUNC_ARG );
27287+ BUFFER_E );
2728027288 /* Good Cases */
2728127289 /* length only */
27282- ExpectIntGT(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, NULL, inLen ), 0);
27290+ ExpectIntGT(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, NULL, 0 ), 0);
2728327291 ExpectIntGT(wc_Ed25519PrivateKeyToDer(&ed25519PrivKey, output, inLen), 0);
2728427292
2728527293 DoExpectIntEQ(wc_FreeRng(&rng), 0);
@@ -27312,10 +27320,10 @@ static int test_wc_Ed448KeyToDer(void)
2731227320 /* Bad Cases */
2731327321 ExpectIntEQ(wc_Ed448KeyToDer(NULL, NULL, 0), BAD_FUNC_ARG);
2731427322 ExpectIntEQ(wc_Ed448KeyToDer(NULL, output, inLen), BAD_FUNC_ARG);
27315- ExpectIntEQ(wc_Ed448KeyToDer(&ed448Key, output, 0), BAD_FUNC_ARG );
27323+ ExpectIntEQ(wc_Ed448KeyToDer(&ed448Key, output, 0), BUFFER_E );
2731627324 /* Good Cases */
2731727325 /* length only */
27318- ExpectIntGT(wc_Ed448KeyToDer(&ed448Key, NULL, inLen ), 0);
27326+ ExpectIntGT(wc_Ed448KeyToDer(&ed448Key, NULL, 0 ), 0);
2731927327 ExpectIntGT(wc_Ed448KeyToDer(&ed448Key, output, inLen), 0);
2732027328
2732127329 DoExpectIntEQ(wc_FreeRng(&rng), 0);
@@ -27350,10 +27358,10 @@ static int test_wc_Ed448PrivateKeyToDer(void)
2735027358 ExpectIntEQ(wc_Ed448PrivateKeyToDer(NULL, NULL, 0), BAD_FUNC_ARG);
2735127359 ExpectIntEQ(wc_Ed448PrivateKeyToDer(NULL, output, inLen), BAD_FUNC_ARG);
2735227360 ExpectIntEQ(wc_Ed448PrivateKeyToDer(&ed448PrivKey, output, 0),
27353- BAD_FUNC_ARG );
27361+ BUFFER_E );
2735427362 /* Good cases */
2735527363 /* length only */
27356- ExpectIntGT(wc_Ed448PrivateKeyToDer(&ed448PrivKey, NULL, inLen ), 0);
27364+ ExpectIntGT(wc_Ed448PrivateKeyToDer(&ed448PrivKey, NULL, 0 ), 0);
2735727365 ExpectIntGT(wc_Ed448PrivateKeyToDer(&ed448PrivKey, output, inLen), 0);
2735827366
2735927367 DoExpectIntEQ(wc_FreeRng(&rng), 0);
@@ -27388,10 +27396,10 @@ static int test_wc_Curve448PrivateKeyToDer(void)
2738827396 ExpectIntEQ(wc_Curve448PrivateKeyToDer(NULL, NULL, 0), BAD_FUNC_ARG);
2738927397 ExpectIntEQ(wc_Curve448PrivateKeyToDer(NULL, output, inLen), BAD_FUNC_ARG);
2739027398 ExpectIntEQ(wc_Curve448PrivateKeyToDer(&curve448PrivKey, output, 0),
27391- BAD_FUNC_ARG );
27399+ BUFFER_E );
2739227400 /* Good cases */
2739327401 /* length only */
27394- ExpectIntGT(wc_Curve448PrivateKeyToDer(&curve448PrivKey, NULL, inLen ), 0);
27402+ ExpectIntGT(wc_Curve448PrivateKeyToDer(&curve448PrivKey, NULL, 0 ), 0);
2739527403 ExpectIntGT(wc_Curve448PrivateKeyToDer(&curve448PrivKey, output, inLen), 0);
2739627404
2739727405 /* Bad Cases */
@@ -27403,8 +27411,8 @@ static int test_wc_Curve448PrivateKeyToDer(void)
2740327411 BUFFER_E);
2740427412 /* Good cases */
2740527413 /* length only */
27406- ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, inLen , 0), 0);
27407- ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, inLen , 1), 0);
27414+ ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, 0 , 0), 0);
27415+ ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, NULL, 0 , 1), 0);
2740827416 ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, output, inLen, 0), 0);
2740927417 ExpectIntGT(wc_Curve448PublicKeyToDer(&curve448PrivKey, output, inLen, 1), 0);
2741027418
0 commit comments