diff options
author | davidben <davidben@chromium.org> | 2016-03-01 15:47:47 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-01 23:48:37 +0000 |
commit | 7dad2a3ec1c5eada75bdd6af49a17c85113814e8 (patch) | |
tree | d8d4121ba870fc4f6554ba562353604a8718fc7d /crypto/auto_cbb.h | |
parent | a4967ca6f74d502d20bf5f99b85d04b155351158 (diff) | |
download | chromium_src-7dad2a3ec1c5eada75bdd6af49a17c85113814e8.zip chromium_src-7dad2a3ec1c5eada75bdd6af49a17c85113814e8.tar.gz chromium_src-7dad2a3ec1c5eada75bdd6af49a17c85113814e8.tar.bz2 |
Cut down on usage of deprecated APIs in //crypto.
SSL_library_init is deprecated. It's CRYPTO_library_init. Switch from the
legacy ASN.1 APIs to the new parsers where feasible.
ECPrivateKey::CreateFromEncryptedPrivateKeyInfo is left alone for now as we
still need a new version of those APIs.
This also adds a scoper for CBB for use in later CLs.
BUG=499653
Review URL: https://codereview.chromium.org/1739403002
Cr-Commit-Position: refs/heads/master@{#378610}
Diffstat (limited to 'crypto/auto_cbb.h')
-rw-r--r-- | crypto/auto_cbb.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/crypto/auto_cbb.h b/crypto/auto_cbb.h new file mode 100644 index 0000000..5206a21 --- /dev/null +++ b/crypto/auto_cbb.h @@ -0,0 +1,35 @@ +// Copyright 2016 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_AUTO_CBB_H_ +#define CRYPTO_AUTO_CBB_H_ + +#include <openssl/bytestring.h> + +#include "base/macros.h" + +namespace crypto { + +// AutoCBB is a wrapper over OpenSSL's CBB type that automatically releases +// resources when going out of scope. +class AutoCBB { + public: + AutoCBB() { CBB_zero(&cbb_); } + ~AutoCBB() { CBB_cleanup(&cbb_); } + + CBB* get() { return &cbb_; } + + void Reset() { + CBB_cleanup(&cbb_); + CBB_zero(&cbb_); + } + + private: + CBB cbb_; + DISALLOW_COPY_AND_ASSIGN(AutoCBB); +}; + +} // namespace crypto + +#endif // CRYPTO_AUTO_CBB_H_ |