@@ -458,8 +458,8 @@ static void TestSquare(BIGNUMFileTest *t, BN_CTX *ctx) {
458
458
SCOPED_TRACE (num_a);
459
459
size_t num_r = 2 * num_a;
460
460
// Use newly-allocated buffers so ASan will catch out-of-bounds writes.
461
- std::unique_ptr <BN_ULONG[]> a_words ( new BN_ULONG[ num_a]),
462
- r_words ( new BN_ULONG[num_r] );
461
+ auto a_words = std::make_unique <BN_ULONG[]>( num_a);
462
+ auto r_words = std::make_unique< BN_ULONG[]>(num_r );
463
463
ASSERT_TRUE (bn_copy_words (a_words.get (), num_a, a.get ()));
464
464
465
465
bn_mul_small (r_words.get (), num_r, a_words.get (), num_a, a_words.get (),
@@ -525,8 +525,9 @@ static void TestProduct(BIGNUMFileTest *t, BN_CTX *ctx) {
525
525
SCOPED_TRACE (num_b);
526
526
size_t num_r = num_a + num_b;
527
527
// Use newly-allocated buffers so ASan will catch out-of-bounds writes.
528
- std::unique_ptr<BN_ULONG[]> a_words (new BN_ULONG[num_a]),
529
- b_words (new BN_ULONG[num_b]), r_words (new BN_ULONG[num_r]);
528
+ auto a_words = std::make_unique<BN_ULONG[]>(num_a);
529
+ auto b_words = std::make_unique<BN_ULONG[]>(num_b);
530
+ auto r_words = std::make_unique<BN_ULONG[]>(num_r);
530
531
ASSERT_TRUE (bn_copy_words (a_words.get (), num_a, a.get ()));
531
532
ASSERT_TRUE (bn_copy_words (b_words.get (), num_b, b.get ()));
532
533
@@ -672,8 +673,9 @@ static void TestModMul(BIGNUMFileTest *t, BN_CTX *ctx) {
672
673
#if !defined(BORINGSSL_SHARED_LIBRARY)
673
674
size_t m_width = static_cast <size_t >(bn_minimal_width (m.get ()));
674
675
if (m_width <= BN_SMALL_MAX_WORDS) {
675
- std::unique_ptr<BN_ULONG[]> a_words (new BN_ULONG[m_width]),
676
- b_words (new BN_ULONG[m_width]), r_words (new BN_ULONG[m_width]);
676
+ auto a_words = std::make_unique<BN_ULONG[]>(m_width);
677
+ auto b_words = std::make_unique<BN_ULONG[]>(m_width);
678
+ auto r_words = std::make_unique<BN_ULONG[]>(m_width);
677
679
ASSERT_TRUE (bn_copy_words (a_words.get (), m_width, a.get ()));
678
680
ASSERT_TRUE (bn_copy_words (b_words.get (), m_width, b.get ()));
679
681
bn_to_montgomery_small (a_words.get (), a_words.get (), m_width, mont.get ());
@@ -691,7 +693,7 @@ static void TestModMul(BIGNUMFileTest *t, BN_CTX *ctx) {
691
693
// inputs. Test this by running |bn_from_montgomery_small| on the result
692
694
// of a product. Note |a_words| * |b_words| has an extra factor of R^2, so
693
695
// we must reduce twice.
694
- std::unique_ptr <BN_ULONG[]> prod_words ( new BN_ULONG[ m_width * 2 ] );
696
+ auto prod_words = std::make_unique <BN_ULONG[]>( m_width * 2 );
695
697
bn_mul_small (prod_words.get (), m_width * 2 , a_words.get (), m_width,
696
698
b_words.get (), m_width);
697
699
bn_from_montgomery_small (r_words.get (), m_width, prod_words.get (),
@@ -752,8 +754,9 @@ static void TestModSquare(BIGNUMFileTest *t, BN_CTX *ctx) {
752
754
#if !defined(BORINGSSL_SHARED_LIBRARY)
753
755
size_t m_width = static_cast <size_t >(bn_minimal_width (m.get ()));
754
756
if (m_width <= BN_SMALL_MAX_WORDS) {
755
- std::unique_ptr<BN_ULONG[]> a_words (new BN_ULONG[m_width]),
756
- a_copy_words (new BN_ULONG[m_width]), r_words (new BN_ULONG[m_width]);
757
+ auto a_words = std::make_unique<BN_ULONG[]>(m_width);
758
+ auto a_copy_words = std::make_unique<BN_ULONG[]>(m_width);
759
+ auto r_words = std::make_unique<BN_ULONG[]>(m_width);
757
760
ASSERT_TRUE (bn_copy_words (a_words.get (), m_width, a.get ()));
758
761
bn_to_montgomery_small (a_words.get (), a_words.get (), m_width, mont.get ());
759
762
bn_mod_mul_montgomery_small (r_words.get (), a_words.get (), a_words.get (),
@@ -815,8 +818,8 @@ static void TestModExp(BIGNUMFileTest *t, BN_CTX *ctx) {
815
818
bssl::UniquePtr<BN_MONT_CTX> mont (
816
819
BN_MONT_CTX_new_for_modulus (m.get (), ctx));
817
820
ASSERT_TRUE (mont.get ());
818
- std::unique_ptr <BN_ULONG[]> r_words ( new BN_ULONG[ m_width]),
819
- a_words ( new BN_ULONG[m_width] );
821
+ auto r_words = std::make_unique <BN_ULONG[]>( m_width);
822
+ auto a_words = std::make_unique< BN_ULONG[]>(m_width );
820
823
ASSERT_TRUE (bn_copy_words (a_words.get (), m_width, a.get ()));
821
824
bn_to_montgomery_small (a_words.get (), a_words.get (), m_width, mont.get ());
822
825
bn_mod_exp_mont_small (r_words.get (), a_words.get (), m_width, e->d ,
0 commit comments