libpurple/ciphers/sha256.c

Thu, 23 Mar 2017 21:01:15 +0300

author
qarkai <qarkai@gmail.com>
date
Thu, 23 Mar 2017 21:01:15 +0300
branch
string-comparison-r2
changeset 38258
9a6551eba09c
parent 31553
45a14a4b0a87
permissions
-rw-r--r--

Replace !strcmp() with purple_strequal()
Didn't touch finch/libgnt files

31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 #include <cipher.h>
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
31430
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
24 #if !GLIB_CHECK_VERSION(2,16,0)
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
31430
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
26 #define SHA256_HMAC_BLOCK_SIZE 64
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #define SHA256_ROTR(X,n) ((((X) >> (n)) | ((X) << (32-(n)))) & 0xFFFFFFFF)
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 static const guint32 sha256_K[64] =
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 };
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 struct SHA256Context {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 guint32 H[8];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 guint32 W[64];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 gint lenW;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 guint32 sizeHi;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 guint32 sizeLo;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 };
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
31430
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
51 static size_t
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
52 sha256_get_block_size(PurpleCipherContext *context)
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
53 {
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
54 /* This does not change (in this case) */
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
55 return SHA256_HMAC_BLOCK_SIZE;
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
56 }
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
57
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 static void
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 sha256_hash_block(struct SHA256Context *sha256_ctx) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 gint i;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 guint32 A, B, C, D, E, F, G, H, T1, T2;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 for(i = 16; i < 64; i++) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 sha256_ctx->W[i] =
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 (SHA256_ROTR(sha256_ctx->W[i-2], 17) ^ SHA256_ROTR(sha256_ctx->W[i-2], 19) ^ (sha256_ctx->W[i-2] >> 10))
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 + sha256_ctx->W[i-7]
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 + (SHA256_ROTR(sha256_ctx->W[i-15], 7) ^ SHA256_ROTR(sha256_ctx->W[i-15], 18) ^ (sha256_ctx->W[i-15] >> 3))
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 + sha256_ctx->W[i-16];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 A = sha256_ctx->H[0];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 B = sha256_ctx->H[1];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 C = sha256_ctx->H[2];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 D = sha256_ctx->H[3];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 E = sha256_ctx->H[4];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 F = sha256_ctx->H[5];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 G = sha256_ctx->H[6];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 H = sha256_ctx->H[7];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 for(i = 0; i < 64; i++) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 T1 = H
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 + (SHA256_ROTR(E, 6) ^ SHA256_ROTR(E, 11) ^ SHA256_ROTR(E, 25))
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 + ((E & F) ^ ((~E) & G))
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 + sha256_K[i] + sha256_ctx->W[i];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 T2 = (SHA256_ROTR(A, 2) ^ SHA256_ROTR(A, 13) ^ SHA256_ROTR(A, 22))
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 + ((A & B) ^ (A & C) ^ (B & C));
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 H = G;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 G = F;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 F = E;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 E = D + T1;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 D = C;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 C = B;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 B = A;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 A = T1 + T2;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 sha256_ctx->H[0] += A;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 sha256_ctx->H[1] += B;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 sha256_ctx->H[2] += C;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 sha256_ctx->H[3] += D;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 sha256_ctx->H[4] += E;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 sha256_ctx->H[5] += F;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 sha256_ctx->H[6] += G;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 sha256_ctx->H[7] += H;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 static void
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 sha256_set_opt(PurpleCipherContext *context, const gchar *name, void *value) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 struct SHA256Context *ctx;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 ctx = purple_cipher_context_get_data(context);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31553
diff changeset
113 if(purple_strequal(name, "sizeHi")) {
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 ctx->sizeHi = GPOINTER_TO_INT(value);
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31553
diff changeset
115 } else if(purple_strequal(name, "sizeLo")) {
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 ctx->sizeLo = GPOINTER_TO_INT(value);
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31553
diff changeset
117 } else if(purple_strequal(name, "lenW")) {
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 ctx->lenW = GPOINTER_TO_INT(value);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 static void *
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 sha256_get_opt(PurpleCipherContext *context, const gchar *name) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 struct SHA256Context *ctx;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 ctx = purple_cipher_context_get_data(context);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31553
diff changeset
128 if(purple_strequal(name, "sizeHi")) {
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 return GINT_TO_POINTER(ctx->sizeHi);
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31553
diff changeset
130 } else if(purple_strequal(name, "sizeLo")) {
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 return GINT_TO_POINTER(ctx->sizeLo);
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 31553
diff changeset
132 } else if(purple_strequal(name, "lenW")) {
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 return GINT_TO_POINTER(ctx->lenW);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 return NULL;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 static void
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 sha256_init(PurpleCipherContext *context, void *extra) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 struct SHA256Context *sha256_ctx;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 sha256_ctx = g_new0(struct SHA256Context, 1);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 purple_cipher_context_set_data(context, sha256_ctx);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 purple_cipher_context_reset(context, extra);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 sha256_reset(PurpleCipherContext *context, void *extra) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 struct SHA256Context *sha256_ctx;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 gint i;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 sha256_ctx = purple_cipher_context_get_data(context);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 g_return_if_fail(sha256_ctx);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 sha256_ctx->lenW = 0;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 sha256_ctx->sizeHi = 0;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 sha256_ctx->sizeLo = 0;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 sha256_ctx->H[0] = 0x6a09e667;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 sha256_ctx->H[1] = 0xbb67ae85;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 sha256_ctx->H[2] = 0x3c6ef372;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 sha256_ctx->H[3] = 0xa54ff53a;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 sha256_ctx->H[4] = 0x510e527f;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 sha256_ctx->H[5] = 0x9b05688c;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 sha256_ctx->H[6] = 0x1f83d9ab;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 sha256_ctx->H[7] = 0x5be0cd19;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 for(i = 0; i < 64; i++)
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 sha256_ctx->W[i] = 0;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 static void
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 sha256_uninit(PurpleCipherContext *context) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 struct SHA256Context *sha256_ctx;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 purple_cipher_context_reset(context, NULL);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 sha256_ctx = purple_cipher_context_get_data(context);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 memset(sha256_ctx, 0, sizeof(struct SHA256Context));
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 g_free(sha256_ctx);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 sha256_ctx = NULL;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 static void
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 sha256_append(PurpleCipherContext *context, const guchar *data, size_t len) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 struct SHA256Context *sha256_ctx;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 gint i;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 sha256_ctx = purple_cipher_context_get_data(context);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 g_return_if_fail(sha256_ctx);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 for(i = 0; i < len; i++) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 sha256_ctx->W[sha256_ctx->lenW / 4] <<= 8;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 sha256_ctx->W[sha256_ctx->lenW / 4] |= data[i];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 if((++sha256_ctx->lenW) % 64 == 0) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 sha256_hash_block(sha256_ctx);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 sha256_ctx->lenW = 0;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 sha256_ctx->sizeLo += 8;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 sha256_ctx->sizeHi += (sha256_ctx->sizeLo < 8);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 static gboolean
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 sha256_digest(PurpleCipherContext *context, size_t in_len, guchar digest[32],
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 size_t *out_len)
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 struct SHA256Context *sha256_ctx;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 guchar pad0x80 = 0x80, pad0x00 = 0x00;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 guchar padlen[8];
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 gint i;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 g_return_val_if_fail(in_len >= 32, FALSE);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 sha256_ctx = purple_cipher_context_get_data(context);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 g_return_val_if_fail(sha256_ctx, FALSE);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 padlen[0] = (guchar)((sha256_ctx->sizeHi >> 24) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 padlen[1] = (guchar)((sha256_ctx->sizeHi >> 16) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 padlen[2] = (guchar)((sha256_ctx->sizeHi >> 8) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 padlen[3] = (guchar)((sha256_ctx->sizeHi >> 0) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 padlen[4] = (guchar)((sha256_ctx->sizeLo >> 24) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 padlen[5] = (guchar)((sha256_ctx->sizeLo >> 16) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 padlen[6] = (guchar)((sha256_ctx->sizeLo >> 8) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 padlen[7] = (guchar)((sha256_ctx->sizeLo >> 0) & 255);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 /* pad with a 1, then zeroes, then length */
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 purple_cipher_context_append(context, &pad0x80, 1);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 while(sha256_ctx->lenW != 56)
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 purple_cipher_context_append(context, &pad0x00, 1);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 purple_cipher_context_append(context, padlen, 8);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 for(i = 0; i < 32; i++) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 digest[i] = (guchar)(sha256_ctx->H[i / 4] >> 24);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 sha256_ctx->H[i / 4] <<= 8;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 purple_cipher_context_reset(context, NULL);
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 if(out_len)
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 *out_len = 32;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 return TRUE;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 static PurpleCipherOps SHA256Ops = {
31553
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
257 sha256_set_opt, /* Set Option */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
258 sha256_get_opt, /* Get Option */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
259 sha256_init, /* init */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
260 sha256_reset, /* reset */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
261 sha256_uninit, /* uninit */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
262 NULL, /* set iv */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
263 sha256_append, /* append */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
264 sha256_digest, /* digest */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
265 NULL, /* encrypt */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
266 NULL, /* decrypt */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
267 NULL, /* set salt */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
268 NULL, /* get salt size */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
269 NULL, /* set key */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
270 NULL, /* get key size */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
271 NULL, /* set batch mode */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
272 NULL, /* get batch mode */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
273 sha256_get_block_size, /* get block size */
45a14a4b0a87 Named initializers and most other C99isms don't work in Visual C++ .NET 2005 in
Florian Quèze <florian@instantbird.org>
parents: 31430
diff changeset
274 NULL /* set key with len */
31426
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 };
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 PurpleCipherOps *
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 purple_sha256_cipher_get_ops(void) {
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 return &SHA256Ops;
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 }
290d182e7bf9 Moved sha256 to the sub library
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281
31430
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
282 #endif /* !GLIB_CHECK_VERSION(2,16,0) */
c7d983ab0bfa Removed the "new" api I added by moving it to ciphers/gchecksum.c. Moved the gchecksum implements into gchecksum.c as a preproc macro, removed them from their individual files
Gary Kramlich <grim@reaperworld.com>
parents: 31428
diff changeset
283

mercurial