[M120 Migration][VD] Remove accessing oom_score_adj in zygote process
[platform/framework/web/chromium-efl.git] / crypto / encryptor.h
index 0775e1a..88ebb88 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Copyright 2012 The Chromium Authors
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 
 #include <memory>
 #include <string>
+#include <string_view>
 
 #include "base/containers/span.h"
-#include "base/optional.h"
-#include "base/strings/string_piece.h"
+#include "base/memory/raw_ptr.h"
 #include "build/build_config.h"
 #include "crypto/crypto_export.h"
+#include "third_party/abseil-cpp/absl/types/optional.h"
 
 namespace crypto {
 
@@ -23,7 +24,7 @@ class SymmetricKey;
 
 // This class implements encryption without authentication, which is usually
 // unsafe. Prefer crypto::Aead for new code. If using this class, prefer the
-// base::span and std::vector overloads over the base::StringPiece and
+// base::span and std::vector overloads over the std::string_view and
 // std::string overloads.
 class CRYPTO_EXPORT Encryptor {
  public:
@@ -40,12 +41,12 @@ class CRYPTO_EXPORT Encryptor {
   //
   // If |mode| is CBC, |iv| must not be empty; if it is CTR, then |iv| must be
   // empty.
-  bool Init(const SymmetricKey* key, Mode mode, base::StringPiece iv);
+  bool Init(const SymmetricKey* key, Mode mode, std::string_view iv);
   bool Init(const SymmetricKey* key, Mode mode, base::span<const uint8_t> iv);
 
   // Encrypts |plaintext| into |ciphertext|.  |plaintext| may only be empty if
   // the mode is CBC.
-  bool Encrypt(base::StringPiece plaintext, std::string* ciphertext);
+  bool Encrypt(std::string_view plaintext, std::string* ciphertext);
   bool Encrypt(base::span<const uint8_t> plaintext,
                std::vector<uint8_t>* ciphertext);
 
@@ -58,7 +59,7 @@ class CRYPTO_EXPORT Encryptor {
   // must either authenticate the ciphertext before decrypting it, or take
   // care to not report decryption failure. Otherwise it could inadvertently
   // be used as a padding oracle to attack the cryptosystem.
-  bool Decrypt(base::StringPiece ciphertext, std::string* plaintext);
+  bool Decrypt(std::string_view ciphertext, std::string* plaintext);
   bool Decrypt(base::span<const uint8_t> ciphertext,
                std::vector<uint8_t>* plaintext);
 
@@ -66,17 +67,17 @@ class CRYPTO_EXPORT Encryptor {
   // counter value is supported.
   //
   // Returns true only if update was successful.
-  bool SetCounter(base::StringPiece counter);
+  bool SetCounter(std::string_view counter);
   bool SetCounter(base::span<const uint8_t> counter);
 
   // TODO(albertb): Support streaming encryption.
 
  private:
-  const SymmetricKey* key_;
+  raw_ptr<const SymmetricKey, DanglingUntriaged> key_;
   Mode mode_;
 
   bool CryptString(bool do_encrypt,
-                   base::StringPiece input,
+                   std::string_view input,
                    std::string* output);
   bool CryptBytes(bool do_encrypt,
                   base::span<const uint8_t> input,
@@ -85,10 +86,10 @@ class CRYPTO_EXPORT Encryptor {
   // On success, these helper functions return the number of bytes written to
   // |output|.
   size_t MaxOutput(bool do_encrypt, size_t length);
-  base::Optional<size_t> Crypt(bool do_encrypt,
+  absl::optional<size_t> Crypt(bool do_encrypt,
                                base::span<const uint8_t> input,
                                base::span<uint8_t> output);
-  base::Optional<size_t> CryptCTR(bool do_encrypt,
+  absl::optional<size_t> CryptCTR(bool do_encrypt,
                                   base::span<const uint8_t> input,
                                   base::span<uint8_t> output);