GDAL
cpl_sha256.h
1
2/* The MIT License
3
4 Copyright (C) 2011 Zilong Tan (tzlloch@gmail.com)
5 Copyright (C) 2015 Even Rouault <even.rouault at spatialys.com>
6
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
22 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
23 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 SOFTWARE.
26*/
27
28#ifndef CPL_SHA256_INCLUDED_H
29#define CPL_SHA256_INCLUDED_H
30
31#ifndef DOXYGEN_SKIP
32
33#include "cpl_port.h"
34
35#define CPL_SHA256_HASH_SIZE 32 /* 256 bit */
36#define CPL_SHA256_HASH_WORDS 8
37
38#ifndef GUInt64
39#define GUInt64 GUIntBig
40#endif
41
43
44struct _CPL_SHA256Context
45{
46 GUInt64 totalLength;
47 GUInt32 hash[CPL_SHA256_HASH_WORDS];
48 GUInt32 bufferLength;
49
50 union
51 {
52 GUInt32 words[16];
53 GByte bytes[64];
54 } buffer;
55};
56typedef struct _CPL_SHA256Context CPL_SHA256Context;
57
58void CPL_DLL CPL_SHA256Init(CPL_SHA256Context *sc);
59
60void CPL_DLL CPL_SHA256Update(CPL_SHA256Context *sc, const void *data,
61 size_t len);
62
63void CPL_DLL CPL_SHA256Final(CPL_SHA256Context *sc,
64 GByte hash[CPL_SHA256_HASH_SIZE]);
65
66void CPL_DLL CPL_SHA256(const void *data, size_t len,
67 GByte hash[CPL_SHA256_HASH_SIZE]);
68
69void CPL_DLL CPL_HMAC_SHA256(const void *pKey, size_t nKeyLen,
70 const void *pabyMessage, size_t nMessageLen,
71 GByte abyDigest[CPL_SHA256_HASH_SIZE]);
72
73// Not exported for now
74GByte *CPL_RSA_SHA256_Sign(const char *pszPrivateKey, const void *pabyData,
75 unsigned int nDataLen, unsigned int *pnSignatureLen);
76
78
79#endif /* #ifndef DOXYGEN_SKIP */
80
81#endif /* CPL_SHA256_INCLUDED_H */
Core portability definitions for CPL.
#define CPL_C_END
Macro to end a block of C symbols.
Definition cpl_port.h:289
#define CPL_C_START
Macro to start a block of C symbols.
Definition cpl_port.h:285
unsigned int GUInt32
Unsigned int32 type.
Definition cpl_port.h:167
GUIntBig GUInt64
Unsigned 64 bit integer type.
Definition cpl_port.h:228
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:175