pk11_keygen.h (950B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 #include "nss.h" 6 #include "secoid.h" 7 8 #include "nss_scoped_ptrs.h" 9 10 namespace nss_test { 11 12 class ParamHolder; 13 14 class Pkcs11KeyPairGenerator { 15 public: 16 Pkcs11KeyPairGenerator(CK_MECHANISM_TYPE mech, SECOidTag curve_oid) 17 : mech_(mech), curve_(curve_oid) {} 18 Pkcs11KeyPairGenerator(CK_MECHANISM_TYPE mech) 19 : Pkcs11KeyPairGenerator(mech, SEC_OID_UNKNOWN) {} 20 21 CK_MECHANISM_TYPE mechanism() const { return mech_; } 22 SECOidTag curve() const { return curve_; } 23 24 void GenerateKey(ScopedSECKEYPrivateKey* priv_key, 25 ScopedSECKEYPublicKey* pub_key, bool sensitive = true) const; 26 27 private: 28 std::unique_ptr<ParamHolder> MakeParams() const; 29 30 CK_MECHANISM_TYPE mech_; 31 SECOidTag curve_; 32 }; 33 34 } // namespace nss_test