czmq-ffi-gen 0.9.2-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/AUTHORS +1 -0
- data/CHANGES.md +92 -0
- data/Gemfile +2 -0
- data/LICENSE +14 -0
- data/README.md +112 -0
- data/lib/czmq-ffi-gen.rb +7 -0
- data/lib/czmq-ffi-gen/czmq/ffi.rb +1210 -0
- data/lib/czmq-ffi-gen/czmq/ffi/version.rb +15 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zactor.rb +186 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zarmour.rb +286 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zcert.rb +307 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zcertstore.rb +222 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zchunk.rb +388 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zclock.rb +140 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zconfig.rb +442 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdigest.rb +156 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdir.rb +283 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zdir_patch.rb +194 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zfile.rb +353 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zframe.rb +359 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zhash.rb +416 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zhashx.rb +659 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ziflist.rb +189 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zlist.rb +365 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zlistx.rb +478 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zloop.rb +396 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zmsg.rb +515 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zpoller.rb +194 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zproc.rb +294 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zsock.rb +3479 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zstr.rb +203 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ztimerset.rb +203 -0
- data/lib/czmq-ffi-gen/czmq/ffi/ztrie.rb +221 -0
- data/lib/czmq-ffi-gen/czmq/ffi/zuuid.rb +227 -0
- data/lib/czmq-ffi-gen/errors.rb +12 -0
- data/lib/czmq-ffi-gen/gem_version.rb +5 -0
- data/lib/czmq-ffi-gen/legacy.rb +16 -0
- data/lib/czmq-ffi-gen/libzmq.rb +18 -0
- data/lib/czmq-ffi-gen/signals.rb +27 -0
- data/lib/czmq-ffi-gen/vendor.rb +5 -0
- data/lib/czmq-ffi-gen/versions.rb +19 -0
- data/vendor/local/bin/inproc_lat.exe +0 -0
- data/vendor/local/bin/inproc_thr.exe +0 -0
- data/vendor/local/bin/libczmq.dll +0 -0
- data/vendor/local/bin/libgcc_s_seh-1.dll +0 -0
- data/vendor/local/bin/libstdc++-6.dll +0 -0
- data/vendor/local/bin/libzmq.dll +0 -0
- data/vendor/local/bin/local_lat.exe +0 -0
- data/vendor/local/bin/local_thr.exe +0 -0
- data/vendor/local/bin/remote_lat.exe +0 -0
- data/vendor/local/bin/remote_thr.exe +0 -0
- data/vendor/local/include/czmq.h +31 -0
- data/vendor/local/include/czmq_library.h +199 -0
- data/vendor/local/include/czmq_prelude.h +641 -0
- data/vendor/local/include/readme.txt +83 -0
- data/vendor/local/include/sha1.h +76 -0
- data/vendor/local/include/sha1.inc_c +335 -0
- data/vendor/local/include/slre.h +92 -0
- data/vendor/local/include/slre.inc_c +660 -0
- data/vendor/local/include/zactor.h +76 -0
- data/vendor/local/include/zarmour.h +114 -0
- data/vendor/local/include/zauth.h +100 -0
- data/vendor/local/include/zauth_v2.h +88 -0
- data/vendor/local/include/zbeacon.h +86 -0
- data/vendor/local/include/zbeacon_v2.h +75 -0
- data/vendor/local/include/zcert.h +136 -0
- data/vendor/local/include/zcertstore.h +100 -0
- data/vendor/local/include/zchunk.h +163 -0
- data/vendor/local/include/zclock.h +73 -0
- data/vendor/local/include/zconfig.h +185 -0
- data/vendor/local/include/zctx.h +107 -0
- data/vendor/local/include/zdigest.h +65 -0
- data/vendor/local/include/zdir.h +149 -0
- data/vendor/local/include/zdir_patch.h +82 -0
- data/vendor/local/include/zfile.h +177 -0
- data/vendor/local/include/zframe.h +176 -0
- data/vendor/local/include/zgossip.h +95 -0
- data/vendor/local/include/zgossip_engine.inc +927 -0
- data/vendor/local/include/zgossip_msg.h +129 -0
- data/vendor/local/include/zhash.h +195 -0
- data/vendor/local/include/zhash_primes.inc +329 -0
- data/vendor/local/include/zhashx.h +298 -0
- data/vendor/local/include/ziflist.h +77 -0
- data/vendor/local/include/zlist.h +158 -0
- data/vendor/local/include/zlistx.h +205 -0
- data/vendor/local/include/zloop.h +168 -0
- data/vendor/local/include/zmonitor.h +73 -0
- data/vendor/local/include/zmonitor_v2.h +56 -0
- data/vendor/local/include/zmq.h +617 -0
- data/vendor/local/include/zmq_utils.h +48 -0
- data/vendor/local/include/zmsg.h +280 -0
- data/vendor/local/include/zmutex.h +55 -0
- data/vendor/local/include/zpoller.h +92 -0
- data/vendor/local/include/zproc.h +168 -0
- data/vendor/local/include/zproxy.h +111 -0
- data/vendor/local/include/zproxy_v2.h +62 -0
- data/vendor/local/include/zrex.h +82 -0
- data/vendor/local/include/zsock.h +912 -0
- data/vendor/local/include/zsock_option.inc +4126 -0
- data/vendor/local/include/zsocket.h +110 -0
- data/vendor/local/include/zsockopt.h +256 -0
- data/vendor/local/include/zstr.h +110 -0
- data/vendor/local/include/zsys.h +386 -0
- data/vendor/local/include/zthread.h +50 -0
- data/vendor/local/include/ztimerset.h +90 -0
- data/vendor/local/include/ztrie.h +106 -0
- data/vendor/local/include/zuuid.h +96 -0
- data/vendor/local/lib/libczmq.dll.a +0 -0
- data/vendor/local/lib/liblibzmq.dll.a +0 -0
- data/vendor/local/lib/libzmq-static.a +0 -0
- data/vendor/local/lib/pkgconfig/libczmq.pc +23 -0
- data/vendor/local/lib/pkgconfig/libzmq.pc +11 -0
- data/vendor/local/share/zmq/AUTHORS.txt +147 -0
- data/vendor/local/share/zmq/COPYING.LESSER.txt +181 -0
- data/vendor/local/share/zmq/COPYING.txt +674 -0
- data/vendor/local/share/zmq/NEWS.txt +978 -0
- metadata +230 -0
@@ -0,0 +1,83 @@
|
|
1
|
+
SLRE - Super Light Regular Expression library
|
2
|
+
|
3
|
+
Modified 2014-08-26 Pieter Hintjens
|
4
|
+
|
5
|
+
SLRE is an ANSI C library that implements a tiny subset of Perl regular expressions. It is primarily targeted for developers who want to parse configuation files, where speed is unimportant. It is in single .c file, easily modifiable for custom needs. For example, if one wants to introduce a new metacharacter, '\i', that means 'IP address', it is easy to do so.
|
6
|
+
|
7
|
+
Features
|
8
|
+
|
9
|
+
Crossplatform - pure ANSI C
|
10
|
+
Very simple API
|
11
|
+
Light: about 5kB of code when compiled
|
12
|
+
Uses no dynamic memory allocation
|
13
|
+
Thread safe
|
14
|
+
Supported RE Syntax
|
15
|
+
|
16
|
+
^ Match beginning of a buffer
|
17
|
+
$ Match end of a buffer
|
18
|
+
() Grouping and substring capturing
|
19
|
+
[...] Match any character from set
|
20
|
+
[^...] Match any character but ones from set
|
21
|
+
. Match any character
|
22
|
+
\s Match whitespace
|
23
|
+
\S Match non-whitespace
|
24
|
+
\d Match decimal digit
|
25
|
+
\D Match non decimal digit
|
26
|
+
\a Match alphabetic character
|
27
|
+
\A Match non-alphabetic character
|
28
|
+
\w Match alphanumeric character
|
29
|
+
\W Match non-alphanumeric character
|
30
|
+
\r Match carriage return
|
31
|
+
\n Match newline
|
32
|
+
+ Match one or more times (greedy)
|
33
|
+
+? Match one or more times (non-greedy)
|
34
|
+
* Match zero or more times (greedy)
|
35
|
+
*? Match zero or more times (non-greedy)
|
36
|
+
? Match zero or once
|
37
|
+
\xDD Match byte with hex value 0xDD
|
38
|
+
\meta Match one of the meta character: ^$().[*+?\
|
39
|
+
API
|
40
|
+
|
41
|
+
Two functions represent the API: one is used for compilations of the RE, the other for performing a match. Both functions return 0 on error, and 1 on success. If the round brackets are used in the RE, then matched substrings can be returned back to the caller in the 'struct cap *' array. Array size must be enough to hold all matches: array_size = number_of_round_bracket_pairs + 1. The first element of the array will always hold the substring matched by the whole RE.
|
42
|
+
|
43
|
+
/* Captured substring */
|
44
|
+
struct cap {
|
45
|
+
const char *ptr; /* Pointer to the substring */
|
46
|
+
int len; /* Substring length */
|
47
|
+
};
|
48
|
+
|
49
|
+
int slre_compile(struct slre *, const char *re);
|
50
|
+
int slre_match(const struct slre *, const char *buf, int buf_len,
|
51
|
+
struct cap *captured_substrings);
|
52
|
+
Usage example
|
53
|
+
|
54
|
+
This example shows how to parse HTTP request line:
|
55
|
+
|
56
|
+
struct slre slre;
|
57
|
+
struct cap captures[4 + 1];
|
58
|
+
|
59
|
+
if (!slre_compile(&slre, "^(GET|POST) (\S+) HTTP/(\S+?)\r\n") {
|
60
|
+
printf("Error compiling RE: %s\n", slre.err_str);
|
61
|
+
} else if (!slre_match(&slre, buf, len, captures)) {
|
62
|
+
printf("Not a valid HTTP request\n" );
|
63
|
+
} else {
|
64
|
+
printf("Request line length: %d\n", captures[0].len);
|
65
|
+
printf("Method: %.*s\n", captures[1].len, captures[1].ptr);
|
66
|
+
printf("URI: %.*s\n", captures[2].len, captures[2].ptr);
|
67
|
+
}
|
68
|
+
Download
|
69
|
+
|
70
|
+
Version 1.0: slre.h, slre.c
|
71
|
+
License
|
72
|
+
|
73
|
+
/*
|
74
|
+
* ----------------------------------------------------------------------------
|
75
|
+
* "THE BEER-WARE LICENSE" (Revision 42):
|
76
|
+
* Sergey Lyubka wrote this file. As long as you retain this notice you
|
77
|
+
* can do whatever you want with this stuff. If we meet some day, and you think
|
78
|
+
* this stuff is worth it, you can buy me a beer in return.
|
79
|
+
* ----------------------------------------------------------------------------
|
80
|
+
*/
|
81
|
+
Author
|
82
|
+
|
83
|
+
Copyright © by Sergey Lyubka (valenok at gmail dot com). Feel free to contact me if you want to comply with the license.
|
@@ -0,0 +1,76 @@
|
|
1
|
+
/* contrib/pgcrypto/sha1.h */
|
2
|
+
/* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */
|
3
|
+
|
4
|
+
/*
|
5
|
+
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
6
|
+
* All rights reserved.
|
7
|
+
*
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
9
|
+
* modification, are permitted provided that the following conditions
|
10
|
+
* are met:
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
16
|
+
* 3. Neither the name of the project nor the names of its contributors
|
17
|
+
* may be used to endorse or promote products derived from this software
|
18
|
+
* without specific prior written permission.
|
19
|
+
*
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
21
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
22
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
23
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
24
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
25
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
26
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
27
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
28
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
29
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
30
|
+
* SUCH DAMAGE.
|
31
|
+
*/
|
32
|
+
/*
|
33
|
+
* FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
|
34
|
+
* based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm
|
35
|
+
* implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
|
36
|
+
*/
|
37
|
+
|
38
|
+
#ifndef _NETINET6_SHA1_H_
|
39
|
+
#define _NETINET6_SHA1_H_
|
40
|
+
|
41
|
+
struct sha1_ctxt
|
42
|
+
{
|
43
|
+
union
|
44
|
+
{
|
45
|
+
uint8_t b8[20];
|
46
|
+
uint32_t b32[5];
|
47
|
+
} h;
|
48
|
+
union
|
49
|
+
{
|
50
|
+
uint8_t b8[8];
|
51
|
+
uint64_t b64[1];
|
52
|
+
} c;
|
53
|
+
union
|
54
|
+
{
|
55
|
+
uint8_t b8[64];
|
56
|
+
uint32_t b32[16];
|
57
|
+
} m;
|
58
|
+
uint8_t count;
|
59
|
+
};
|
60
|
+
|
61
|
+
extern void sha1_init(struct sha1_ctxt *);
|
62
|
+
extern void sha1_pad(struct sha1_ctxt *);
|
63
|
+
extern void sha1_loop(struct sha1_ctxt *, const uint8_t *, size_t);
|
64
|
+
extern void sha1_result(struct sha1_ctxt *, uint8_t *);
|
65
|
+
|
66
|
+
// Compatibility with OpenSSL API
|
67
|
+
#define SHA_DIGEST_LENGTH 20
|
68
|
+
typedef struct sha1_ctxt SHA_CTX;
|
69
|
+
|
70
|
+
#define SHA1_Init(x) sha1_init((x))
|
71
|
+
#define SHA1_Update(x, y, z) sha1_loop((x), (y), (z))
|
72
|
+
#define SHA1_Final(x, y) sha1_result((y), (x))
|
73
|
+
|
74
|
+
#define SHA1_RESULTLEN (160/8)
|
75
|
+
|
76
|
+
#endif /* _NETINET6_SHA1_H_ */
|
@@ -0,0 +1,335 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
3
|
+
* All rights reserved.
|
4
|
+
*
|
5
|
+
* Redistribution and use in source and binary forms, with or without
|
6
|
+
* modification, are permitted provided that the following conditions
|
7
|
+
* are met:
|
8
|
+
* 1. Redistributions of source code must retain the above copyright
|
9
|
+
* notice, this list of conditions and the following disclaimer.
|
10
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
11
|
+
* notice, this list of conditions and the following disclaimer in the
|
12
|
+
* documentation and/or other materials provided with the distribution.
|
13
|
+
* 3. Neither the name of the project nor the names of its contributors
|
14
|
+
* may be used to endorse or promote products derived from this software
|
15
|
+
* without specific prior written permission.
|
16
|
+
*
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
18
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
19
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
21
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
22
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
23
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
24
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
26
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
27
|
+
* SUCH DAMAGE.
|
28
|
+
*/
|
29
|
+
|
30
|
+
/*
|
31
|
+
* FIPS pub 180-1: Secure Hash Algorithm (SHA-1)
|
32
|
+
* based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm
|
33
|
+
* implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
|
34
|
+
*/
|
35
|
+
|
36
|
+
#include "../../../include/czmq.h"
|
37
|
+
#include "sha1.h"
|
38
|
+
|
39
|
+
/* constant table */
|
40
|
+
static uint32_t _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6};
|
41
|
+
|
42
|
+
#define K(t) _K[(t) / 20]
|
43
|
+
|
44
|
+
#define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d)))
|
45
|
+
#define F1(b, c, d) (((b) ^ (c)) ^ (d))
|
46
|
+
#define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d)))
|
47
|
+
#define F3(b, c, d) (((b) ^ (c)) ^ (d))
|
48
|
+
|
49
|
+
#define S(n, x) (((x) << (n)) | ((x) >> (32 - (n))))
|
50
|
+
|
51
|
+
#define H(n) (ctxt->h.b32[(n)])
|
52
|
+
#define COUNT (ctxt->count)
|
53
|
+
#define BCOUNT (ctxt->c.b64[0] / 8)
|
54
|
+
#define W(n) (ctxt->m.b32[(n)])
|
55
|
+
|
56
|
+
#define PUTBYTE(x) \
|
57
|
+
do { \
|
58
|
+
ctxt->m.b8[(COUNT % 64)] = (x); \
|
59
|
+
COUNT++; \
|
60
|
+
COUNT %= 64; \
|
61
|
+
ctxt->c.b64[0] += 8; \
|
62
|
+
if (COUNT % 64 == 0) \
|
63
|
+
sha1_step(ctxt); \
|
64
|
+
} while (0)
|
65
|
+
|
66
|
+
#define PUTPAD(x) \
|
67
|
+
do { \
|
68
|
+
ctxt->m.b8[(COUNT % 64)] = (x); \
|
69
|
+
COUNT++; \
|
70
|
+
COUNT %= 64; \
|
71
|
+
if (COUNT % 64 == 0) \
|
72
|
+
sha1_step(ctxt); \
|
73
|
+
} while (0)
|
74
|
+
|
75
|
+
static void sha1_step(struct sha1_ctxt *);
|
76
|
+
|
77
|
+
static void
|
78
|
+
sha1_step(struct sha1_ctxt * ctxt)
|
79
|
+
{
|
80
|
+
uint32_t a,
|
81
|
+
b,
|
82
|
+
c,
|
83
|
+
d,
|
84
|
+
e;
|
85
|
+
size_t t,
|
86
|
+
s;
|
87
|
+
uint32_t tmp;
|
88
|
+
|
89
|
+
#ifndef WORDS_BIGENDIAN
|
90
|
+
struct sha1_ctxt tctxt;
|
91
|
+
|
92
|
+
memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64);
|
93
|
+
ctxt->m.b8[0] = tctxt.m.b8[3];
|
94
|
+
ctxt->m.b8[1] = tctxt.m.b8[2];
|
95
|
+
ctxt->m.b8[2] = tctxt.m.b8[1];
|
96
|
+
ctxt->m.b8[3] = tctxt.m.b8[0];
|
97
|
+
ctxt->m.b8[4] = tctxt.m.b8[7];
|
98
|
+
ctxt->m.b8[5] = tctxt.m.b8[6];
|
99
|
+
ctxt->m.b8[6] = tctxt.m.b8[5];
|
100
|
+
ctxt->m.b8[7] = tctxt.m.b8[4];
|
101
|
+
ctxt->m.b8[8] = tctxt.m.b8[11];
|
102
|
+
ctxt->m.b8[9] = tctxt.m.b8[10];
|
103
|
+
ctxt->m.b8[10] = tctxt.m.b8[9];
|
104
|
+
ctxt->m.b8[11] = tctxt.m.b8[8];
|
105
|
+
ctxt->m.b8[12] = tctxt.m.b8[15];
|
106
|
+
ctxt->m.b8[13] = tctxt.m.b8[14];
|
107
|
+
ctxt->m.b8[14] = tctxt.m.b8[13];
|
108
|
+
ctxt->m.b8[15] = tctxt.m.b8[12];
|
109
|
+
ctxt->m.b8[16] = tctxt.m.b8[19];
|
110
|
+
ctxt->m.b8[17] = tctxt.m.b8[18];
|
111
|
+
ctxt->m.b8[18] = tctxt.m.b8[17];
|
112
|
+
ctxt->m.b8[19] = tctxt.m.b8[16];
|
113
|
+
ctxt->m.b8[20] = tctxt.m.b8[23];
|
114
|
+
ctxt->m.b8[21] = tctxt.m.b8[22];
|
115
|
+
ctxt->m.b8[22] = tctxt.m.b8[21];
|
116
|
+
ctxt->m.b8[23] = tctxt.m.b8[20];
|
117
|
+
ctxt->m.b8[24] = tctxt.m.b8[27];
|
118
|
+
ctxt->m.b8[25] = tctxt.m.b8[26];
|
119
|
+
ctxt->m.b8[26] = tctxt.m.b8[25];
|
120
|
+
ctxt->m.b8[27] = tctxt.m.b8[24];
|
121
|
+
ctxt->m.b8[28] = tctxt.m.b8[31];
|
122
|
+
ctxt->m.b8[29] = tctxt.m.b8[30];
|
123
|
+
ctxt->m.b8[30] = tctxt.m.b8[29];
|
124
|
+
ctxt->m.b8[31] = tctxt.m.b8[28];
|
125
|
+
ctxt->m.b8[32] = tctxt.m.b8[35];
|
126
|
+
ctxt->m.b8[33] = tctxt.m.b8[34];
|
127
|
+
ctxt->m.b8[34] = tctxt.m.b8[33];
|
128
|
+
ctxt->m.b8[35] = tctxt.m.b8[32];
|
129
|
+
ctxt->m.b8[36] = tctxt.m.b8[39];
|
130
|
+
ctxt->m.b8[37] = tctxt.m.b8[38];
|
131
|
+
ctxt->m.b8[38] = tctxt.m.b8[37];
|
132
|
+
ctxt->m.b8[39] = tctxt.m.b8[36];
|
133
|
+
ctxt->m.b8[40] = tctxt.m.b8[43];
|
134
|
+
ctxt->m.b8[41] = tctxt.m.b8[42];
|
135
|
+
ctxt->m.b8[42] = tctxt.m.b8[41];
|
136
|
+
ctxt->m.b8[43] = tctxt.m.b8[40];
|
137
|
+
ctxt->m.b8[44] = tctxt.m.b8[47];
|
138
|
+
ctxt->m.b8[45] = tctxt.m.b8[46];
|
139
|
+
ctxt->m.b8[46] = tctxt.m.b8[45];
|
140
|
+
ctxt->m.b8[47] = tctxt.m.b8[44];
|
141
|
+
ctxt->m.b8[48] = tctxt.m.b8[51];
|
142
|
+
ctxt->m.b8[49] = tctxt.m.b8[50];
|
143
|
+
ctxt->m.b8[50] = tctxt.m.b8[49];
|
144
|
+
ctxt->m.b8[51] = tctxt.m.b8[48];
|
145
|
+
ctxt->m.b8[52] = tctxt.m.b8[55];
|
146
|
+
ctxt->m.b8[53] = tctxt.m.b8[54];
|
147
|
+
ctxt->m.b8[54] = tctxt.m.b8[53];
|
148
|
+
ctxt->m.b8[55] = tctxt.m.b8[52];
|
149
|
+
ctxt->m.b8[56] = tctxt.m.b8[59];
|
150
|
+
ctxt->m.b8[57] = tctxt.m.b8[58];
|
151
|
+
ctxt->m.b8[58] = tctxt.m.b8[57];
|
152
|
+
ctxt->m.b8[59] = tctxt.m.b8[56];
|
153
|
+
ctxt->m.b8[60] = tctxt.m.b8[63];
|
154
|
+
ctxt->m.b8[61] = tctxt.m.b8[62];
|
155
|
+
ctxt->m.b8[62] = tctxt.m.b8[61];
|
156
|
+
ctxt->m.b8[63] = tctxt.m.b8[60];
|
157
|
+
#endif
|
158
|
+
|
159
|
+
a = H(0);
|
160
|
+
b = H(1);
|
161
|
+
c = H(2);
|
162
|
+
d = H(3);
|
163
|
+
e = H(4);
|
164
|
+
|
165
|
+
for (t = 0; t < 20; t++)
|
166
|
+
{
|
167
|
+
s = t & 0x0f;
|
168
|
+
if (t >= 16)
|
169
|
+
W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s));
|
170
|
+
tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t);
|
171
|
+
e = d;
|
172
|
+
d = c;
|
173
|
+
c = S(30, b);
|
174
|
+
b = a;
|
175
|
+
a = tmp;
|
176
|
+
}
|
177
|
+
for (t = 20; t < 40; t++)
|
178
|
+
{
|
179
|
+
s = t & 0x0f;
|
180
|
+
W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s));
|
181
|
+
tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t);
|
182
|
+
e = d;
|
183
|
+
d = c;
|
184
|
+
c = S(30, b);
|
185
|
+
b = a;
|
186
|
+
a = tmp;
|
187
|
+
}
|
188
|
+
for (t = 40; t < 60; t++)
|
189
|
+
{
|
190
|
+
s = t & 0x0f;
|
191
|
+
W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s));
|
192
|
+
tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t);
|
193
|
+
e = d;
|
194
|
+
d = c;
|
195
|
+
c = S(30, b);
|
196
|
+
b = a;
|
197
|
+
a = tmp;
|
198
|
+
}
|
199
|
+
for (t = 60; t < 80; t++)
|
200
|
+
{
|
201
|
+
s = t & 0x0f;
|
202
|
+
W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s));
|
203
|
+
tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t);
|
204
|
+
e = d;
|
205
|
+
d = c;
|
206
|
+
c = S(30, b);
|
207
|
+
b = a;
|
208
|
+
a = tmp;
|
209
|
+
}
|
210
|
+
|
211
|
+
H(0) = H(0) + a;
|
212
|
+
H(1) = H(1) + b;
|
213
|
+
H(2) = H(2) + c;
|
214
|
+
H(3) = H(3) + d;
|
215
|
+
H(4) = H(4) + e;
|
216
|
+
|
217
|
+
memset(&ctxt->m.b8[0], 0, 64);
|
218
|
+
}
|
219
|
+
|
220
|
+
/*------------------------------------------------------------*/
|
221
|
+
|
222
|
+
void
|
223
|
+
sha1_init(struct sha1_ctxt * ctxt)
|
224
|
+
{
|
225
|
+
memset(ctxt, 0, sizeof(struct sha1_ctxt));
|
226
|
+
H(0) = 0x67452301;
|
227
|
+
H(1) = 0xefcdab89;
|
228
|
+
H(2) = 0x98badcfe;
|
229
|
+
H(3) = 0x10325476;
|
230
|
+
H(4) = 0xc3d2e1f0;
|
231
|
+
}
|
232
|
+
|
233
|
+
void
|
234
|
+
sha1_pad(struct sha1_ctxt * ctxt)
|
235
|
+
{
|
236
|
+
size_t padlen; /* pad length in bytes */
|
237
|
+
size_t padstart;
|
238
|
+
|
239
|
+
PUTPAD(0x80);
|
240
|
+
|
241
|
+
padstart = COUNT % 64;
|
242
|
+
padlen = 64 - padstart;
|
243
|
+
if (padlen < 8)
|
244
|
+
{
|
245
|
+
memset(&ctxt->m.b8[padstart], 0, padlen);
|
246
|
+
COUNT += (uint8_t) padlen;
|
247
|
+
COUNT %= 64;
|
248
|
+
sha1_step(ctxt);
|
249
|
+
padstart = COUNT % 64; /* should be 0 */
|
250
|
+
padlen = 64 - padstart; /* should be 64 */
|
251
|
+
}
|
252
|
+
memset(&ctxt->m.b8[padstart], 0, padlen - 8);
|
253
|
+
COUNT += ((uint8_t) padlen - 8);
|
254
|
+
COUNT %= 64;
|
255
|
+
#ifdef WORDS_BIGENDIAN
|
256
|
+
PUTPAD(ctxt->c.b8[0]);
|
257
|
+
PUTPAD(ctxt->c.b8[1]);
|
258
|
+
PUTPAD(ctxt->c.b8[2]);
|
259
|
+
PUTPAD(ctxt->c.b8[3]);
|
260
|
+
PUTPAD(ctxt->c.b8[4]);
|
261
|
+
PUTPAD(ctxt->c.b8[5]);
|
262
|
+
PUTPAD(ctxt->c.b8[6]);
|
263
|
+
PUTPAD(ctxt->c.b8[7]);
|
264
|
+
#else
|
265
|
+
PUTPAD(ctxt->c.b8[7]);
|
266
|
+
PUTPAD(ctxt->c.b8[6]);
|
267
|
+
PUTPAD(ctxt->c.b8[5]);
|
268
|
+
PUTPAD(ctxt->c.b8[4]);
|
269
|
+
PUTPAD(ctxt->c.b8[3]);
|
270
|
+
PUTPAD(ctxt->c.b8[2]);
|
271
|
+
PUTPAD(ctxt->c.b8[1]);
|
272
|
+
PUTPAD(ctxt->c.b8[0]);
|
273
|
+
#endif
|
274
|
+
}
|
275
|
+
|
276
|
+
void
|
277
|
+
sha1_loop(struct sha1_ctxt * ctxt, const uint8_t *input0, size_t len)
|
278
|
+
{
|
279
|
+
const uint8_t *input;
|
280
|
+
size_t gaplen;
|
281
|
+
size_t gapstart;
|
282
|
+
size_t off;
|
283
|
+
size_t copysiz;
|
284
|
+
|
285
|
+
input = (const uint8_t *) input0;
|
286
|
+
off = 0;
|
287
|
+
|
288
|
+
while (off < len)
|
289
|
+
{
|
290
|
+
gapstart = COUNT % 64;
|
291
|
+
gaplen = 64 - gapstart;
|
292
|
+
|
293
|
+
copysiz = (gaplen < len - off) ? gaplen : len - off;
|
294
|
+
memmove(&ctxt->m.b8[gapstart], &input[off], copysiz);
|
295
|
+
COUNT += (uint8_t) copysiz;
|
296
|
+
COUNT %= 64;
|
297
|
+
ctxt->c.b64[0] += copysiz * 8;
|
298
|
+
if (COUNT % 64 == 0)
|
299
|
+
sha1_step(ctxt);
|
300
|
+
off += copysiz;
|
301
|
+
}
|
302
|
+
}
|
303
|
+
|
304
|
+
void
|
305
|
+
sha1_result(struct sha1_ctxt * ctxt, uint8_t *digest0)
|
306
|
+
{
|
307
|
+
uint8_t *digest;
|
308
|
+
|
309
|
+
digest = (uint8_t *) digest0;
|
310
|
+
sha1_pad(ctxt);
|
311
|
+
#ifdef WORDS_BIGENDIAN
|
312
|
+
memmove(digest, &ctxt->h.b8[0], 20);
|
313
|
+
#else
|
314
|
+
digest[0] = ctxt->h.b8[3];
|
315
|
+
digest[1] = ctxt->h.b8[2];
|
316
|
+
digest[2] = ctxt->h.b8[1];
|
317
|
+
digest[3] = ctxt->h.b8[0];
|
318
|
+
digest[4] = ctxt->h.b8[7];
|
319
|
+
digest[5] = ctxt->h.b8[6];
|
320
|
+
digest[6] = ctxt->h.b8[5];
|
321
|
+
digest[7] = ctxt->h.b8[4];
|
322
|
+
digest[8] = ctxt->h.b8[11];
|
323
|
+
digest[9] = ctxt->h.b8[10];
|
324
|
+
digest[10] = ctxt->h.b8[9];
|
325
|
+
digest[11] = ctxt->h.b8[8];
|
326
|
+
digest[12] = ctxt->h.b8[15];
|
327
|
+
digest[13] = ctxt->h.b8[14];
|
328
|
+
digest[14] = ctxt->h.b8[13];
|
329
|
+
digest[15] = ctxt->h.b8[12];
|
330
|
+
digest[16] = ctxt->h.b8[19];
|
331
|
+
digest[17] = ctxt->h.b8[18];
|
332
|
+
digest[18] = ctxt->h.b8[17];
|
333
|
+
digest[19] = ctxt->h.b8[16];
|
334
|
+
#endif
|
335
|
+
}
|