1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_quota_DummyCipherStrategy_h
8 #define mozilla_dom_quota_DummyCipherStrategy_h
15 #include "ErrorList.h"
16 #include "mozilla/Result.h"
17 #include "mozilla/Span.h"
18 #include "mozilla/dom/quota/CipherStrategy.h"
20 namespace mozilla::dom::quota
{
22 struct DummyCipherStrategy
{
25 static constexpr size_t BlockPrefixLength
= 8;
26 static constexpr size_t BasicBlockSize
= 4;
28 static void DummyTransform(Span
<const uint8_t> aIn
, Span
<uint8_t> aOut
) {
29 std::transform(aIn
.cbegin(), aIn
.cend(), aOut
.begin(),
30 [](const uint8_t byte
) { return byte
^ 42; });
33 static Result
<KeyType
, nsresult
> GenerateKey() { return KeyType
{}; }
35 nsresult
Init(CipherMode aCipherMode
, Span
<const uint8_t> aKey
,
36 Span
<const uint8_t> aInitialIv
= Span
<const uint8_t>{}) {
40 nsresult
Cipher(Span
<uint8_t> aIv
, Span
<const uint8_t> aIn
,
42 DummyTransform(aIn
, aOut
);
46 static std::array
<uint8_t, BlockPrefixLength
> MakeBlockPrefix() {
47 return {{42, 43, 44, 45}};
50 static Span
<const uint8_t> SerializeKey(const KeyType
&) { return {}; }
52 static Maybe
<KeyType
> DeserializeKey(const Span
<const uint8_t>&) {
53 return Some(KeyType
{});
56 } // namespace mozilla::dom::quota