|
| |||||||||||||
#include "libjwgc.h"#include "libxode.h"Go to the source code of this file.
Defines | |
| #define | SHA_ROTL(X, n) ((((X) << (n)) | ((X) >> (32-(n)))) & 0xffffffffL) |
Functions | |
| void | j_shaInit (j_SHA_CTX *ctx) |
| void | j_shaUpdate (j_SHA_CTX *ctx, unsigned char *dataIn, int len) |
| void | j_shaFinal (j_SHA_CTX *ctx, unsigned char hashout[20]) |
| void | j_shaBlock (unsigned char *dataIn, int len, unsigned char hashout[20]) |
| char * | j_shahash (char *str) |
| void | j_shahash_r (const char *str, char hashbuf[41]) |
|
|
|
|
||||||||||||||||
|
Definition at line 110 of file JSha.c. References j_shaFinal(), j_shaInit(), and j_shaUpdate(). Referenced by j_shahash(), and j_shahash_r(). 00111 {
00112 j_SHA_CTX ctx;
00113
00114 j_shaInit(&ctx);
00115 j_shaUpdate(&ctx, dataIn, len);
00116 j_shaFinal(&ctx, hashout);
00117 }
|
|
||||||||||||
|
Definition at line 71 of file JSha.c. References j_SHA_CTX::H, j_shaInit(), j_shaUpdate(), j_SHA_CTX::lenW, j_SHA_CTX::sizeHi, and j_SHA_CTX::sizeLo. Referenced by j_shaBlock(). 00072 {
00073 unsigned char pad0x80 = 0x80;
00074 unsigned char pad0x00 = 0x00;
00075 unsigned char padlen[8];
00076 int i;
00077
00078 /*
00079 * Pad with a binary 1 (e.g. 0x80), then zeroes, then length
00080 */
00081 padlen[0] = (unsigned char) ((ctx->sizeHi >> 24) & 255);
00082 padlen[1] = (unsigned char) ((ctx->sizeHi >> 16) & 255);
00083 padlen[2] = (unsigned char) ((ctx->sizeHi >> 8) & 255);
00084 padlen[3] = (unsigned char) ((ctx->sizeHi >> 0) & 255);
00085 padlen[4] = (unsigned char) ((ctx->sizeLo >> 24) & 255);
00086 padlen[5] = (unsigned char) ((ctx->sizeLo >> 16) & 255);
00087 padlen[6] = (unsigned char) ((ctx->sizeLo >> 8) & 255);
00088 padlen[7] = (unsigned char) ((ctx->sizeLo >> 0) & 255);
00089 j_shaUpdate(ctx, &pad0x80, 1);
00090 while (ctx->lenW != 56)
00091 j_shaUpdate(ctx, &pad0x00, 1);
00092 j_shaUpdate(ctx, padlen, 8);
00093
00094 /*
00095 * Output hash
00096 */
00097 for (i = 0; i < 20; i++) {
00098 hashout[i] = (unsigned char) (ctx->H[i / 4] >> 24);
00099 ctx->H[i / 4] <<= 8;
00100 }
00101
00102 /*
00103 * Re-initialize the context (also zeroizes contents)
00104 */
00105 j_shaInit(ctx);
00106 }
|
|
|
Definition at line 184 of file JSha.c. References j_shaBlock(), and snprintf. Referenced by jab_auth(), and jabutil_regkey(). 00185 {
00186 static char final[41];
00187 char *pos;
00188 unsigned char hashval[20];
00189 int x;
00190
00191 if (!str || strlen(str) == 0)
00192 return NULL;
00193
00194 j_shaBlock((unsigned char *) str, strlen(str), hashval);
00195
00196 pos = final;
00197 for (x = 0; x < 20; x++) {
00198 snprintf(pos, 3, "%02x", hashval[x]);
00199 pos += 2;
00200 }
00201 return (char *) final;
00202 }
|
|
||||||||||||
|
Definition at line 205 of file JSha.c. References j_shaBlock(), and snprintf. 00206 {
00207 int x;
00208 char *pos;
00209 unsigned char hashval[20];
00210
00211 if (!str || strlen(str) == 0)
00212 return;
00213
00214 j_shaBlock((unsigned char *) str, strlen(str), hashval);
00215
00216 pos = hashbuf;
00217 for (x = 0; x < 20; x++) {
00218 snprintf(pos, 3, "%02x", hashval[x]);
00219 pos += 2;
00220 }
00221
00222 return;
00223 }
|
|
|
Definition at line 28 of file JSha.c. References j_SHA_CTX::H, j_SHA_CTX::lenW, j_SHA_CTX::sizeHi, j_SHA_CTX::sizeLo, and j_SHA_CTX::W. Referenced by j_shaBlock(), and j_shaFinal(). 00029 {
00030 int i;
00031
00032 ctx->lenW = 0;
00033 ctx->sizeHi = ctx->sizeLo = 0;
00034
00035 /*
00036 * Initialize H with the magic constants (see FIPS180 for constants)
00037 */
00038 ctx->H[0] = 0x67452301L;
00039 ctx->H[1] = 0xefcdab89L;
00040 ctx->H[2] = 0x98badcfeL;
00041 ctx->H[3] = 0x10325476L;
00042 ctx->H[4] = 0xc3d2e1f0L;
00043
00044 for (i = 0; i < 80; i++)
00045 ctx->W[i] = 0;
00046 }
|
|
||||||||||||||||
|
Definition at line 50 of file JSha.c. References j_SHA_CTX::lenW, j_SHA_CTX::sizeHi, j_SHA_CTX::sizeLo, and j_SHA_CTX::W. Referenced by j_shaBlock(), and j_shaFinal(). 00051 {
00052 int i;
00053
00054 /*
00055 * Read the data into W and process blocks as they get full
00056 */
00057 for (i = 0; i < len; i++) {
00058 ctx->W[ctx->lenW / 4] <<= 8;
00059 ctx->W[ctx->lenW / 4] |= (unsigned long) dataIn[i];
00060 if ((++ctx->lenW) % 64 == 0) {
00061 j_shaHashBlock(ctx);
00062 ctx->lenW = 0;
00063 }
00064 ctx->sizeLo += 8;
00065 ctx->sizeHi += (ctx->sizeLo < 8);
00066 }
00067 }
|
| Last updated at Tue Dec 18 21:07:42 PST 2007. | This site and project hosted by... |