// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CRYPTO_SCOPED_NSS_TYPES_H_ #define CRYPTO_SCOPED_NSS_TYPES_H_ #include #include #include #include #include namespace crypto { template struct NSSDestroyer { void operator()(Type* ptr) const { Destroyer(ptr); } }; template struct NSSDestroyer1 { void operator()(Type* ptr) const { Destroyer(ptr, freeit); } }; // Define some convenient scopers around NSS pointers. typedef std::unique_ptr< PK11Context, NSSDestroyer1> ScopedPK11Context; typedef std::unique_ptr> ScopedPK11Slot; typedef std::unique_ptr> ScopedPK11SlotList; typedef std::unique_ptr> ScopedPK11SymKey; typedef std::unique_ptr> ScopedSECKEYPublicKey; typedef std::unique_ptr< SECKEYPrivateKey, NSSDestroyer> ScopedSECKEYPrivateKey; typedef std::unique_ptr< SECAlgorithmID, NSSDestroyer1> ScopedSECAlgorithmID; typedef std::unique_ptr> ScopedSECItem; typedef std::unique_ptr> ScopedPLArenaPool; } // namespace crypto #endif // CRYPTO_SCOPED_NSS_TYPES_H_