summaryrefslogtreecommitdiffstats
path: root/security/nss/gtests/freebl_gtest/rsa_unittest.cc
diff options
context:
space:
mode:
authorjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-28 07:38:20 +0200
committerjanekptacijarabaci <janekptacijarabaci@seznam.cz>2018-04-28 07:38:20 +0200
commit6b2bba06b433fb75979ab6daf7bbe8bc76c53875 (patch)
tree75803b4683889e6e0d2a3faef30415db3ff7b3ba /security/nss/gtests/freebl_gtest/rsa_unittest.cc
parent72def35cd0cf3649b6d7ab72b66117df3e1c33fc (diff)
parentc75dae3ed21bfa5a8ae46cd83d18329af5bea05a (diff)
downloadUXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar.gz
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar.lz
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.tar.xz
UXP-6b2bba06b433fb75979ab6daf7bbe8bc76c53875.zip
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into pm_url_1
Diffstat (limited to 'security/nss/gtests/freebl_gtest/rsa_unittest.cc')
-rw-r--r--security/nss/gtests/freebl_gtest/rsa_unittest.cc61
1 files changed, 0 insertions, 61 deletions
diff --git a/security/nss/gtests/freebl_gtest/rsa_unittest.cc b/security/nss/gtests/freebl_gtest/rsa_unittest.cc
deleted file mode 100644
index 5c667a1d1..000000000
--- a/security/nss/gtests/freebl_gtest/rsa_unittest.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// This Source Code Form is subject to the terms of the Mozilla Public
-// License, v. 2.0. If a copy of the MPL was not distributed with this file,
-// You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#include "gtest/gtest.h"
-
-#include <stdint.h>
-
-#include "blapi.h"
-#include "secitem.h"
-
-template <class T>
-struct ScopedDelete {
- void operator()(T* ptr) {
- if (ptr) {
- PORT_FreeArena(ptr->arena, PR_TRUE);
- }
- }
-};
-
-typedef std::unique_ptr<RSAPrivateKey, ScopedDelete<RSAPrivateKey>>
- ScopedRSAPrivateKey;
-
-class RSANewKeyTest : public ::testing::Test {
- protected:
- RSAPrivateKey* CreateKeyWithExponent(int keySizeInBits,
- unsigned char publicExponent) {
- SECItem exp = {siBuffer, 0, 0};
- unsigned char pubExp[1] = {publicExponent};
- exp.data = pubExp;
- exp.len = 1;
-
- return RSA_NewKey(keySizeInBits, &exp);
- }
-};
-
-TEST_F(RSANewKeyTest, expOneTest) {
- ScopedRSAPrivateKey key(CreateKeyWithExponent(2048, 0x01));
- ASSERT_TRUE(key == nullptr);
-}
-TEST_F(RSANewKeyTest, expTwoTest) {
- ScopedRSAPrivateKey key(CreateKeyWithExponent(2048, 0x02));
- ASSERT_TRUE(key == nullptr);
-}
-TEST_F(RSANewKeyTest, expFourTest) {
- ScopedRSAPrivateKey key(CreateKeyWithExponent(2048, 0x04));
- ASSERT_TRUE(key == nullptr);
-}
-TEST_F(RSANewKeyTest, WrongKeysizeTest) {
- ScopedRSAPrivateKey key(CreateKeyWithExponent(2047, 0x03));
- ASSERT_TRUE(key == nullptr);
-}
-
-TEST_F(RSANewKeyTest, expThreeTest) {
- ScopedRSAPrivateKey key(CreateKeyWithExponent(2048, 0x03));
-#ifdef NSS_FIPS_DISABLED
- ASSERT_TRUE(key != nullptr);
-#else
- ASSERT_TRUE(key == nullptr);
-#endif
-}