When GL implementation is Mock or None return rather than setting the skia-gpu GL...
[chromium-blink-merge.git] / crypto / secure_hash_default.cc
blobb24221b55ca091b92a5eb24660c7cbcd9540fb34
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "crypto/secure_hash.h"
7 #include "base/logging.h"
8 #include "crypto/third_party/nss/blapi.h"
9 #include "crypto/third_party/nss/sha256.h"
11 namespace crypto {
13 namespace {
15 class SecureHashSHA256NSS : public SecureHash {
16 public:
17 SecureHashSHA256NSS() {
18 SHA256_Begin(&ctx_);
21 virtual ~SecureHashSHA256NSS() {
24 virtual void Update(const void* input, size_t len) {
25 SHA256_Update(&ctx_, static_cast<const unsigned char*>(input), len);
28 virtual void Finish(void* output, size_t len) {
29 SHA256_End(&ctx_, static_cast<unsigned char*>(output), NULL,
30 static_cast<unsigned int>(len));
33 private:
34 SHA256Context ctx_;
37 } // namespace
39 SecureHash* SecureHash::Create(Algorithm algorithm) {
40 switch (algorithm) {
41 case SHA256:
42 return new SecureHashSHA256NSS();
43 default:
44 NOTIMPLEMENTED();
45 return NULL;
49 } // namespace crypto