Coverage Report

Created: 2026-08-08 07:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/boringssl/crypto/fipsmodule/aes/ofb.cc.inc
Line
Count
Source
1
// Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#include <assert.h>
16
#include <string.h>
17
18
#include "internal.h"
19
20
21
using namespace bssl;
22
23
static_assert(16 % sizeof(size_t) == 0, "block cannot be divided into size_t");
24
25
void bssl::CRYPTO_ofb128_encrypt(const uint8_t *in, uint8_t *out, size_t len,
26
                                 const AES_KEY *key, uint8_t ivec[16],
27
0
                                 unsigned *num, block128_f block) {
28
0
  assert(key != nullptr && ivec != nullptr && num != nullptr);
29
0
  assert(len == 0 || (in != nullptr && out != nullptr));
30
31
0
  unsigned n = *num;
32
33
0
  while (n && len) {
34
0
    *(out++) = *(in++) ^ ivec[n];
35
0
    --len;
36
0
    n = (n + 1) % 16;
37
0
  }
38
39
0
  while (len >= 16) {
40
0
    (*block)(ivec, ivec, key);
41
0
    CRYPTO_xor16(out, in, ivec);
42
0
    len -= 16;
43
0
    out += 16;
44
0
    in += 16;
45
0
    n = 0;
46
0
  }
47
0
  if (len) {
48
0
    (*block)(ivec, ivec, key);
49
0
    while (len--) {
50
0
      out[n] = in[n] ^ ivec[n];
51
0
      ++n;
52
0
    }
53
0
  }
54
0
  *num = n;
55
0
}