OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <openssl/evp.h> | 5 #include <openssl/evp.h> |
6 | 6 |
7 #include "base/stl_util.h" | |
8 #include "components/webcrypto/algorithms/rsa.h" | 7 #include "components/webcrypto/algorithms/rsa.h" |
9 #include "components/webcrypto/algorithms/util.h" | 8 #include "components/webcrypto/algorithms/util.h" |
10 #include "components/webcrypto/blink_key_handle.h" | 9 #include "components/webcrypto/blink_key_handle.h" |
11 #include "components/webcrypto/crypto_data.h" | 10 #include "components/webcrypto/crypto_data.h" |
12 #include "components/webcrypto/status.h" | 11 #include "components/webcrypto/status.h" |
13 #include "crypto/openssl_util.h" | 12 #include "crypto/openssl_util.h" |
14 #include "crypto/scoped_openssl_types.h" | 13 #include "crypto/scoped_openssl_types.h" |
15 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" | 14 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" |
16 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" | 15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" |
17 | 16 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 | 72 |
74 // Determine the maximum length of the output. | 73 // Determine the maximum length of the output. |
75 size_t outlen = 0; | 74 size_t outlen = 0; |
76 if (!encrypt_decrypt_func(ctx.get(), NULL, &outlen, data.bytes(), | 75 if (!encrypt_decrypt_func(ctx.get(), NULL, &outlen, data.bytes(), |
77 data.byte_length())) { | 76 data.byte_length())) { |
78 return Status::OperationError(); | 77 return Status::OperationError(); |
79 } | 78 } |
80 buffer->resize(outlen); | 79 buffer->resize(outlen); |
81 | 80 |
82 // Do the actual encryption/decryption. | 81 // Do the actual encryption/decryption. |
83 if (!encrypt_decrypt_func(ctx.get(), vector_as_array(buffer), &outlen, | 82 if (!encrypt_decrypt_func(ctx.get(), buffer->data(), &outlen, data.bytes(), |
84 data.bytes(), data.byte_length())) { | 83 data.byte_length())) { |
85 return Status::OperationError(); | 84 return Status::OperationError(); |
86 } | 85 } |
87 buffer->resize(outlen); | 86 buffer->resize(outlen); |
88 | 87 |
89 return Status::Success(); | 88 return Status::Success(); |
90 } | 89 } |
91 | 90 |
92 class RsaOaepImplementation : public RsaHashedAlgorithm { | 91 class RsaOaepImplementation : public RsaHashedAlgorithm { |
93 public: | 92 public: |
94 RsaOaepImplementation() | 93 RsaOaepImplementation() |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 } | 135 } |
137 }; | 136 }; |
138 | 137 |
139 } // namespace | 138 } // namespace |
140 | 139 |
141 scoped_ptr<AlgorithmImplementation> CreateRsaOaepImplementation() { | 140 scoped_ptr<AlgorithmImplementation> CreateRsaOaepImplementation() { |
142 return make_scoped_ptr(new RsaOaepImplementation); | 141 return make_scoped_ptr(new RsaOaepImplementation); |
143 } | 142 } |
144 | 143 |
145 } // namespace webcrypto | 144 } // namespace webcrypto |
OLD | NEW |