YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/build/debugcov-clang-dynamic-arm64-ninja/postgres_build/src/interfaces/libpq/sha2_openssl.c
Line
Count
Source (jump to first uncovered line)
1
/*-------------------------------------------------------------------------
2
 *
3
 * sha2_openssl.c
4
 *    Set of wrapper routines on top of OpenSSL to support SHA-224
5
 *    SHA-256, SHA-384 and SHA-512 functions.
6
 *
7
 * This should only be used if code is compiled with OpenSSL support.
8
 *
9
 * Portions Copyright (c) 2016-2018, PostgreSQL Global Development Group
10
 *
11
 * IDENTIFICATION
12
 *      src/common/sha2_openssl.c
13
 *
14
 *-------------------------------------------------------------------------
15
 */
16
17
#ifndef FRONTEND
18
#include "postgres.h"
19
#else
20
#include "postgres_fe.h"
21
#endif
22
23
#include <openssl/sha.h>
24
25
#include "common/sha2.h"
26
27
28
/* Interface routines for SHA-256 */
29
void
30
pg_sha256_init(pg_sha256_ctx *ctx)
31
32.7k
{
32
32.7k
  SHA256_Init((SHA256_CTX *) ctx);
33
32.7k
}
34
35
void
36
pg_sha256_update(pg_sha256_ctx *ctx, const uint8 *data, size_t len)
37
65.5k
{
38
65.5k
  SHA256_Update((SHA256_CTX *) ctx, data, len);
39
65.5k
}
40
41
void
42
pg_sha256_final(pg_sha256_ctx *ctx, uint8 *dest)
43
32.7k
{
44
32.7k
  SHA256_Final(dest, (SHA256_CTX *) ctx);
45
32.7k
}
46
47
/* Interface routines for SHA-512 */
48
void
49
pg_sha512_init(pg_sha512_ctx *ctx)
50
0
{
51
0
  SHA512_Init((SHA512_CTX *) ctx);
52
0
}
53
54
void
55
pg_sha512_update(pg_sha512_ctx *ctx, const uint8 *data, size_t len)
56
0
{
57
0
  SHA512_Update((SHA512_CTX *) ctx, data, len);
58
0
}
59
60
void
61
pg_sha512_final(pg_sha512_ctx *ctx, uint8 *dest)
62
0
{
63
0
  SHA512_Final(dest, (SHA512_CTX *) ctx);
64
0
}
65
66
/* Interface routines for SHA-384 */
67
void
68
pg_sha384_init(pg_sha384_ctx *ctx)
69
0
{
70
0
  SHA384_Init((SHA512_CTX *) ctx);
71
0
}
72
73
void
74
pg_sha384_update(pg_sha384_ctx *ctx, const uint8 *data, size_t len)
75
0
{
76
0
  SHA384_Update((SHA512_CTX *) ctx, data, len);
77
0
}
78
79
void
80
pg_sha384_final(pg_sha384_ctx *ctx, uint8 *dest)
81
0
{
82
0
  SHA384_Final(dest, (SHA512_CTX *) ctx);
83
0
}
84
85
/* Interface routines for SHA-224 */
86
void
87
pg_sha224_init(pg_sha224_ctx *ctx)
88
0
{
89
0
  SHA224_Init((SHA256_CTX *) ctx);
90
0
}
91
92
void
93
pg_sha224_update(pg_sha224_ctx *ctx, const uint8 *data, size_t len)
94
0
{
95
0
  SHA224_Update((SHA256_CTX *) ctx, data, len);
96
0
}
97
98
void
99
pg_sha224_final(pg_sha224_ctx *ctx, uint8 *dest)
100
0
{
101
0
  SHA224_Final(dest, (SHA256_CTX *) ctx);
102
0
}