forked from Pissandshittium/pissandshittium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec_signature_creator.cc
36 lines (27 loc) · 910 Bytes
/
ec_signature_creator.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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.
#include "crypto/ec_signature_creator.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "crypto/ec_signature_creator_impl.h"
namespace crypto {
namespace {
ECSignatureCreatorFactory* g_factory_ = nullptr;
} // namespace
// static
std::unique_ptr<ECSignatureCreator> ECSignatureCreator::Create(
ECPrivateKey* key) {
if (g_factory_)
return g_factory_->Create(key);
return base::MakeUnique<ECSignatureCreatorImpl>(key);
}
// static
void ECSignatureCreator::SetFactoryForTesting(
ECSignatureCreatorFactory* factory) {
// We should always clear the factory after each test to avoid
// use-after-free problems.
DCHECK(!g_factory_ || !factory);
g_factory_ = factory;
}
} // namespace crypto