PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
internal-sha2.c File Reference
#include "postgres.h"
#include <time.h>
#include "px.h"
#include "sha2.h"
Include dependency graph for internal-sha2.c:

Go to the source code of this file.

Functions

void init_sha224 (PX_MD *h)
 
void init_sha256 (PX_MD *h)
 
void init_sha384 (PX_MD *h)
 
void init_sha512 (PX_MD *h)
 
static unsigned int_sha224_len (PX_MD *h)
 
static unsigned int_sha224_block_len (PX_MD *h)
 
static void int_sha224_update (PX_MD *h, const uint8 *data, unsigned dlen)
 
static void int_sha224_reset (PX_MD *h)
 
static void int_sha224_finish (PX_MD *h, uint8 *dst)
 
static void int_sha224_free (PX_MD *h)
 
static unsigned int_sha256_len (PX_MD *h)
 
static unsigned int_sha256_block_len (PX_MD *h)
 
static void int_sha256_update (PX_MD *h, const uint8 *data, unsigned dlen)
 
static void int_sha256_reset (PX_MD *h)
 
static void int_sha256_finish (PX_MD *h, uint8 *dst)
 
static void int_sha256_free (PX_MD *h)
 
static unsigned int_sha384_len (PX_MD *h)
 
static unsigned int_sha384_block_len (PX_MD *h)
 
static void int_sha384_update (PX_MD *h, const uint8 *data, unsigned dlen)
 
static void int_sha384_reset (PX_MD *h)
 
static void int_sha384_finish (PX_MD *h, uint8 *dst)
 
static void int_sha384_free (PX_MD *h)
 
static unsigned int_sha512_len (PX_MD *h)
 
static unsigned int_sha512_block_len (PX_MD *h)
 
static void int_sha512_update (PX_MD *h, const uint8 *data, unsigned dlen)
 
static void int_sha512_reset (PX_MD *h)
 
static void int_sha512_finish (PX_MD *h, uint8 *dst)
 
static void int_sha512_free (PX_MD *h)
 

Function Documentation

void init_sha224 ( PX_MD h)

Definition at line 239 of file internal-sha2.c.

References px_digest::block_size, px_digest::finish, px_digest::free, int_sha224_block_len(), int_sha224_finish(), int_sha224_free(), int_sha224_len(), int_sha224_reset(), int_sha224_update(), px_digest::p, px_digest::ptr, px_alloc, px_digest::reset, px_digest::result_size, and px_digest::update.

240 {
241  SHA224_CTX *ctx;
242 
243  ctx = px_alloc(sizeof(*ctx));
244  memset(ctx, 0, sizeof(*ctx));
245 
246  md->p.ptr = ctx;
247 
248  md->result_size = int_sha224_len;
249  md->block_size = int_sha224_block_len;
250  md->reset = int_sha224_reset;
251  md->update = int_sha224_update;
252  md->finish = int_sha224_finish;
253  md->free = int_sha224_free;
254 
255  md->reset(md);
256 }
static void int_sha224_reset(PX_MD *h)
Definition: internal-sha2.c:67
static unsigned int_sha224_block_len(PX_MD *h)
Definition: internal-sha2.c:53
static void int_sha224_update(PX_MD *h, const uint8 *data, unsigned dlen)
Definition: internal-sha2.c:59
static unsigned int_sha224_len(PX_MD *h)
Definition: internal-sha2.c:47
#define px_alloc(s)
Definition: px.h:45
static void int_sha224_free(PX_MD *h)
Definition: internal-sha2.c:83
static void int_sha224_finish(PX_MD *h, uint8 *dst)
Definition: internal-sha2.c:75
void init_sha256 ( PX_MD h)

Definition at line 259 of file internal-sha2.c.

References px_digest::block_size, px_digest::finish, px_digest::free, int_sha256_block_len(), int_sha256_finish(), int_sha256_free(), int_sha256_len(), int_sha256_reset(), int_sha256_update(), px_digest::p, px_digest::ptr, px_alloc, px_digest::reset, px_digest::result_size, and px_digest::update.

260 {
261  SHA256_CTX *ctx;
262 
263  ctx = px_alloc(sizeof(*ctx));
264  memset(ctx, 0, sizeof(*ctx));
265 
266  md->p.ptr = ctx;
267 
268  md->result_size = int_sha256_len;
269  md->block_size = int_sha256_block_len;
270  md->reset = int_sha256_reset;
271  md->update = int_sha256_update;
272  md->finish = int_sha256_finish;
273  md->free = int_sha256_free;
274 
275  md->reset(md);
276 }
static void int_sha256_reset(PX_MD *h)
static unsigned int_sha256_len(PX_MD *h)
Definition: internal-sha2.c:95
static void int_sha256_finish(PX_MD *h, uint8 *dst)
static void int_sha256_update(PX_MD *h, const uint8 *data, unsigned dlen)
static unsigned int_sha256_block_len(PX_MD *h)
#define px_alloc(s)
Definition: px.h:45
static void int_sha256_free(PX_MD *h)
void init_sha384 ( PX_MD h)

Definition at line 279 of file internal-sha2.c.

References px_digest::block_size, px_digest::finish, px_digest::free, int_sha384_block_len(), int_sha384_finish(), int_sha384_free(), int_sha384_len(), int_sha384_reset(), int_sha384_update(), px_digest::p, px_digest::ptr, px_alloc, px_digest::reset, px_digest::result_size, and px_digest::update.

280 {
281  SHA384_CTX *ctx;
282 
283  ctx = px_alloc(sizeof(*ctx));
284  memset(ctx, 0, sizeof(*ctx));
285 
286  md->p.ptr = ctx;
287 
288  md->result_size = int_sha384_len;
289  md->block_size = int_sha384_block_len;
290  md->reset = int_sha384_reset;
291  md->update = int_sha384_update;
292  md->finish = int_sha384_finish;
293  md->free = int_sha384_free;
294 
295  md->reset(md);
296 }
static void int_sha384_update(PX_MD *h, const uint8 *data, unsigned dlen)
static void int_sha384_reset(PX_MD *h)
static unsigned int_sha384_block_len(PX_MD *h)
static void int_sha384_finish(PX_MD *h, uint8 *dst)
static void int_sha384_free(PX_MD *h)
static unsigned int_sha384_len(PX_MD *h)
#define px_alloc(s)
Definition: px.h:45
void init_sha512 ( PX_MD h)

Definition at line 299 of file internal-sha2.c.

References px_digest::block_size, px_digest::finish, px_digest::free, int_sha512_block_len(), int_sha512_finish(), int_sha512_free(), int_sha512_len(), int_sha512_reset(), int_sha512_update(), px_digest::p, px_digest::ptr, px_alloc, px_digest::reset, px_digest::result_size, and px_digest::update.

300 {
301  SHA512_CTX *ctx;
302 
303  ctx = px_alloc(sizeof(*ctx));
304  memset(ctx, 0, sizeof(*ctx));
305 
306  md->p.ptr = ctx;
307 
308  md->result_size = int_sha512_len;
309  md->block_size = int_sha512_block_len;
310  md->reset = int_sha512_reset;
311  md->update = int_sha512_update;
312  md->finish = int_sha512_finish;
313  md->free = int_sha512_free;
314 
315  md->reset(md);
316 }
static unsigned int_sha512_len(PX_MD *h)
static void int_sha512_reset(PX_MD *h)
static void int_sha512_update(PX_MD *h, const uint8 *data, unsigned dlen)
static unsigned int_sha512_block_len(PX_MD *h)
#define px_alloc(s)
Definition: px.h:45
static void int_sha512_finish(PX_MD *h, uint8 *dst)
static void int_sha512_free(PX_MD *h)
static unsigned int_sha224_block_len ( PX_MD h)
static

Definition at line 53 of file internal-sha2.c.

References SHA224_BLOCK_LENGTH.

Referenced by init_sha224().

54 {
55  return SHA224_BLOCK_LENGTH;
56 }
#define SHA224_BLOCK_LENGTH
Definition: sha2.h:53
static void int_sha224_finish ( PX_MD h,
uint8 dst 
)
static

Definition at line 75 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA224_Final().

Referenced by init_sha224().

76 {
77  SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
78 
79  SHA224_Final(dst, ctx);
80 }
void * ptr
Definition: px.h:126
void SHA224_Final(uint8 digest[], SHA224_CTX *context)
Definition: sha2.c:969
union px_digest::@13 p
static void int_sha224_free ( PX_MD h)
static

Definition at line 83 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, px_free, and px_memset().

Referenced by init_sha224().

84 {
85  SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
86 
87  px_memset(ctx, 0, sizeof(*ctx));
88  px_free(ctx);
89  px_free(h);
90 }
void * ptr
Definition: px.h:126
#define px_free(p)
Definition: px.h:47
union px_digest::@13 p
void px_memset(void *ptr, int c, size_t len)
Definition: px.c:134
static unsigned int_sha224_len ( PX_MD h)
static

Definition at line 47 of file internal-sha2.c.

References SHA224_DIGEST_LENGTH.

Referenced by init_sha224().

48 {
49  return SHA224_DIGEST_LENGTH;
50 }
#define SHA224_DIGEST_LENGTH
Definition: sha2.h:54
static void int_sha224_reset ( PX_MD h)
static

Definition at line 67 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA224_Init().

Referenced by init_sha224().

68 {
69  SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
70 
71  SHA224_Init(ctx);
72 }
void * ptr
Definition: px.h:126
void SHA224_Init(SHA224_CTX *context)
Definition: sha2.c:953
union px_digest::@13 p
static void int_sha224_update ( PX_MD h,
const uint8 data,
unsigned  dlen 
)
static

Definition at line 59 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA224_Update().

Referenced by init_sha224().

60 {
61  SHA224_CTX *ctx = (SHA224_CTX *) h->p.ptr;
62 
63  SHA224_Update(ctx, data, dlen);
64 }
void * ptr
Definition: px.h:126
union px_digest::@13 p
void SHA224_Update(SHA224_CTX *context, const uint8 *data, size_t len)
Definition: sha2.c:963
static unsigned int_sha256_block_len ( PX_MD h)
static

Definition at line 101 of file internal-sha2.c.

References SHA256_BLOCK_LENGTH.

Referenced by init_sha256().

102 {
103  return SHA256_BLOCK_LENGTH;
104 }
#define SHA256_BLOCK_LENGTH
Definition: sha2.h:56
static void int_sha256_finish ( PX_MD h,
uint8 dst 
)
static

Definition at line 123 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA256_Final.

Referenced by init_sha256().

124 {
125  SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
126 
127  SHA256_Final(dst, ctx);
128 }
void * ptr
Definition: px.h:126
#define SHA256_Final
Definition: sha2.h:44
union px_digest::@13 p
static void int_sha256_free ( PX_MD h)
static

Definition at line 131 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, px_free, and px_memset().

Referenced by init_sha256().

132 {
133  SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
134 
135  px_memset(ctx, 0, sizeof(*ctx));
136  px_free(ctx);
137  px_free(h);
138 }
void * ptr
Definition: px.h:126
#define px_free(p)
Definition: px.h:47
union px_digest::@13 p
void px_memset(void *ptr, int c, size_t len)
Definition: px.c:134
static unsigned int_sha256_len ( PX_MD h)
static

Definition at line 95 of file internal-sha2.c.

References SHA256_DIGEST_LENGTH.

Referenced by init_sha256().

96 {
97  return SHA256_DIGEST_LENGTH;
98 }
#define SHA256_DIGEST_LENGTH
Definition: sha2.h:57
static void int_sha256_reset ( PX_MD h)
static

Definition at line 115 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA256_Init.

Referenced by init_sha256().

116 {
117  SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
118 
119  SHA256_Init(ctx);
120 }
void * ptr
Definition: px.h:126
#define SHA256_Init
Definition: sha2.h:42
union px_digest::@13 p
static void int_sha256_update ( PX_MD h,
const uint8 data,
unsigned  dlen 
)
static

Definition at line 107 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA256_Update.

Referenced by init_sha256().

108 {
109  SHA256_CTX *ctx = (SHA256_CTX *) h->p.ptr;
110 
111  SHA256_Update(ctx, data, dlen);
112 }
void * ptr
Definition: px.h:126
union px_digest::@13 p
#define SHA256_Update
Definition: sha2.h:43
static unsigned int_sha384_block_len ( PX_MD h)
static

Definition at line 149 of file internal-sha2.c.

References SHA384_BLOCK_LENGTH.

Referenced by init_sha384().

150 {
151  return SHA384_BLOCK_LENGTH;
152 }
#define SHA384_BLOCK_LENGTH
Definition: sha2.h:59
static void int_sha384_finish ( PX_MD h,
uint8 dst 
)
static

Definition at line 171 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA384_Final.

Referenced by init_sha384().

172 {
173  SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
174 
175  SHA384_Final(dst, ctx);
176 }
#define SHA384_Final
Definition: sha2.h:47
void * ptr
Definition: px.h:126
union px_digest::@13 p
static void int_sha384_free ( PX_MD h)
static

Definition at line 179 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, px_free, and px_memset().

Referenced by init_sha384().

180 {
181  SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
182 
183  px_memset(ctx, 0, sizeof(*ctx));
184  px_free(ctx);
185  px_free(h);
186 }
void * ptr
Definition: px.h:126
#define px_free(p)
Definition: px.h:47
union px_digest::@13 p
void px_memset(void *ptr, int c, size_t len)
Definition: px.c:134
static unsigned int_sha384_len ( PX_MD h)
static

Definition at line 143 of file internal-sha2.c.

References SHA384_DIGEST_LENGTH.

Referenced by init_sha384().

144 {
145  return SHA384_DIGEST_LENGTH;
146 }
#define SHA384_DIGEST_LENGTH
Definition: sha2.h:60
static void int_sha384_reset ( PX_MD h)
static

Definition at line 163 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA384_Init.

Referenced by init_sha384().

164 {
165  SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
166 
167  SHA384_Init(ctx);
168 }
void * ptr
Definition: px.h:126
#define SHA384_Init
Definition: sha2.h:45
union px_digest::@13 p
static void int_sha384_update ( PX_MD h,
const uint8 data,
unsigned  dlen 
)
static

Definition at line 155 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA384_Update.

Referenced by init_sha384().

156 {
157  SHA384_CTX *ctx = (SHA384_CTX *) h->p.ptr;
158 
159  SHA384_Update(ctx, data, dlen);
160 }
void * ptr
Definition: px.h:126
#define SHA384_Update
Definition: sha2.h:46
union px_digest::@13 p
static unsigned int_sha512_block_len ( PX_MD h)
static

Definition at line 197 of file internal-sha2.c.

References SHA512_BLOCK_LENGTH.

Referenced by init_sha512().

198 {
199  return SHA512_BLOCK_LENGTH;
200 }
#define SHA512_BLOCK_LENGTH
Definition: sha2.h:62
static void int_sha512_finish ( PX_MD h,
uint8 dst 
)
static

Definition at line 219 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA512_Final.

Referenced by init_sha512().

220 {
221  SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
222 
223  SHA512_Final(dst, ctx);
224 }
void * ptr
Definition: px.h:126
#define SHA512_Final
Definition: sha2.h:50
union px_digest::@13 p
static void int_sha512_free ( PX_MD h)
static

Definition at line 227 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, px_free, and px_memset().

Referenced by init_sha512().

228 {
229  SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
230 
231  px_memset(ctx, 0, sizeof(*ctx));
232  px_free(ctx);
233  px_free(h);
234 }
void * ptr
Definition: px.h:126
#define px_free(p)
Definition: px.h:47
union px_digest::@13 p
void px_memset(void *ptr, int c, size_t len)
Definition: px.c:134
static unsigned int_sha512_len ( PX_MD h)
static

Definition at line 191 of file internal-sha2.c.

References SHA512_DIGEST_LENGTH.

Referenced by init_sha512().

192 {
193  return SHA512_DIGEST_LENGTH;
194 }
#define SHA512_DIGEST_LENGTH
Definition: sha2.h:63
static void int_sha512_reset ( PX_MD h)
static

Definition at line 211 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA512_Init.

Referenced by init_sha512().

212 {
213  SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
214 
215  SHA512_Init(ctx);
216 }
void * ptr
Definition: px.h:126
union px_digest::@13 p
#define SHA512_Init
Definition: sha2.h:48
static void int_sha512_update ( PX_MD h,
const uint8 data,
unsigned  dlen 
)
static

Definition at line 203 of file internal-sha2.c.

References px_digest::p, px_digest::ptr, and SHA512_Update.

Referenced by init_sha512().

204 {
205  SHA512_CTX *ctx = (SHA512_CTX *) h->p.ptr;
206 
207  SHA512_Update(ctx, data, dlen);
208 }
void * ptr
Definition: px.h:126
#define SHA512_Update
Definition: sha2.h:49
union px_digest::@13 p