Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
span_util.h
Go to the documentation of this file.
1// Copyright 2021 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CORE_FXCRT_SPAN_UTIL_H_
6#define CORE_FXCRT_SPAN_UTIL_H_
7
8#include <stdint.h>
9
10#include "core/fxcrt/fx_memcpy_wrappers.h"
11#include "third_party/base/check_op.h"
12#include "third_party/base/containers/span.h"
13
14namespace fxcrt {
15
16// Bounds-checked copies from spans into spans.
17template <typename T,
18 typename U,
20void spancpy(pdfium::span<T> dst, pdfium::span<U> src) {
21 CHECK_GE(dst.size_bytes(), src.size_bytes());
22 FXSYS_memcpy(dst.data(), src.data(), src.size_bytes());
23}
24
25// Bounds-checked moves from spans into spans.
26template <typename T,
27 typename U,
29void spanmove(pdfium::span<T> dst, pdfium::span<U> src) {
30 CHECK_GE(dst.size_bytes(), src.size_bytes());
31 FXSYS_memmove(dst.data(), src.data(), src.size_bytes());
32}
33
34// Bounds-checked sets into spans.
35template <typename T>
36void spanset(pdfium::span<T> dst, uint8_t val) {
37 FXSYS_memset(dst.data(), val, dst.size_bytes());
38}
39
40// Bounds-checked zeroing of spans.
41template <typename T>
42void spanclr(pdfium::span<T> dst) {
43 FXSYS_memset(dst.data(), 0, dst.size_bytes());
44}
45
46template <typename T,
47 typename U,
48 typename = typename std::enable_if_t<std::is_const_v<T> ||
49 !std::is_const_v<U>>>
50inline pdfium::span<T> reinterpret_span(pdfium::span<U> s) noexcept {
51 CHECK_EQ(s.size_bytes() % sizeof(T), 0u);
52 CHECK_EQ(reinterpret_cast<uintptr_t>(s.data()) % alignof(T), 0u);
53 return {reinterpret_cast<T*>(s.data()), s.size_bytes() / sizeof(T)};
54}
55
56} // namespace fxcrt
57
58#endif // CORE_FXCRT_SPAN_UTIL_H_
void CRYPT_MD5Finish(CRYPT_md5_context *context, uint8_t digest[16])
Definition fx_crypt.cpp:214
#define P(a, b, c, d, k, s, t)
#define GET_UINT32(n, b, i)
Definition fx_crypt.cpp:13
#define S(x, n)
void CRYPT_ArcFourCryptBlock(pdfium::span< uint8_t > data, pdfium::span< const uint8_t > key)
Definition fx_crypt.cpp:169
void CRYPT_ArcFourSetup(CRYPT_rc4_context *context, pdfium::span< const uint8_t > key)
Definition fx_crypt.cpp:143
void CRYPT_MD5Update(CRYPT_md5_context *context, pdfium::span< const uint8_t > data)
Definition fx_crypt.cpp:187
#define PUT_UINT32(n, b, i)
Definition fx_crypt.cpp:20
void CRYPT_ArcFourCrypt(CRYPT_rc4_context *context, pdfium::span< uint8_t > data)
Definition fx_crypt.cpp:158
CRYPT_md5_context CRYPT_MD5Start()
Definition fx_crypt.cpp:176
void CRYPT_MD5Generate(pdfium::span< const uint8_t > data, uint8_t digest[16])
Definition fx_crypt.cpp:228
void CRYPT_SHA1Finish(CRYPT_sha1_context *context, uint8_t digest[20])
void CRYPT_SHA384Finish(CRYPT_sha2_context *context, uint8_t digest[48])
void CRYPT_SHA512Update(CRYPT_sha2_context *context, const uint8_t *data, uint32_t size)
void CRYPT_SHA1Generate(const uint8_t *data, uint32_t size, uint8_t digest[20])
void CRYPT_SHA256Generate(const uint8_t *data, uint32_t size, uint8_t digest[32])
void CRYPT_SHA384Start(CRYPT_sha2_context *context)
void CRYPT_SHA512Generate(const uint8_t *data, uint32_t size, uint8_t digest[64])
void CRYPT_SHA512Finish(CRYPT_sha2_context *context, uint8_t digest[64])
void CRYPT_SHA256Update(CRYPT_sha2_context *context, const uint8_t *data, uint32_t size)
void CRYPT_SHA1Update(CRYPT_sha1_context *context, const uint8_t *data, uint32_t size)
void CRYPT_SHA384Update(CRYPT_sha2_context *context, const uint8_t *data, uint32_t size)
void CRYPT_SHA512Start(CRYPT_sha2_context *context)
void CRYPT_SHA256Finish(CRYPT_sha2_context *context, uint8_t digest[32])
void CRYPT_SHA256Start(CRYPT_sha2_context *context)
void CRYPT_SHA1Start(CRYPT_sha1_context *context)
void CRYPT_SHA384Generate(const uint8_t *data, uint32_t size, uint8_t digest[48])
void CRYPT_AESSetIV(CRYPT_aes_context *context, const uint8_t *iv)
void CRYPT_AESEncrypt(CRYPT_aes_context *context, uint8_t *dest, const uint8_t *src, uint32_t size)
void CRYPT_AESSetKey(CRYPT_aes_context *context, const uint8_t *key, uint32_t keylen)
void CRYPT_AESDecrypt(CRYPT_aes_context *context, uint8_t *dest, const uint8_t *src, uint32_t size)
pdfium::span< T > reinterpret_span(pdfium::span< U > s) noexcept
Definition span_util.h:50
void spanclr(pdfium::span< T > dst)
Definition span_util.h:42
void spancpy(pdfium::span< T > dst, pdfium::span< U > src)
Definition span_util.h:20
void spanset(pdfium::span< T > dst, uint8_t val)
Definition span_util.h:36
void spanmove(pdfium::span< T > dst, pdfium::span< U > src)
Definition span_util.h:29
unsigned int iv[kMaxNb]
Definition fx_crypt.h:31
unsigned int keysched[kSchedSize]
Definition fx_crypt.h:29
static constexpr int kMaxNr
Definition fx_crypt.h:24
unsigned int invkeysched[kSchedSize]
Definition fx_crypt.h:30
static constexpr int kSchedSize
Definition fx_crypt.h:25
static constexpr int kMaxNb
Definition fx_crypt.h:23
uint8_t buffer[64]
Definition fx_crypt.h:37
uint32_t state[4]
Definition fx_crypt.h:36
uint32_t total[2]
Definition fx_crypt.h:35
static constexpr int32_t kPermutationLength
Definition fx_crypt.h:15
int32_t m[kPermutationLength]
Definition fx_crypt.h:19
uint64_t total_bytes
Definition fx_crypt.h:41
uint8_t block[64]
Definition fx_crypt.h:44
uint32_t h[5]
Definition fx_crypt.h:43
uint32_t blkused
Definition fx_crypt.h:42
uint64_t state[8]
Definition fx_crypt.h:49
uint64_t total_bytes
Definition fx_crypt.h:48
uint8_t buffer[128]
Definition fx_crypt.h:50