MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / sha_transform

Function sha_transform

src/common/sha.cpp:127–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125// do SHA transformation
126
127static void sha_transform(SHA_INFO *sha_info)
128{
129 int i;
130 Sha1::LONG W[80];
131
132 const BYTE* dp = sha_info->data;
133
134/*
135the following makes sure that at least one code block below is
136traversed or an error is reported, without the necessity for nested
137preprocessor if/else/endif blocks, which are a great pain in the
138nether regions of the anatomy...
139*/
140#undef SWAP_DONE
141
142#if (SHA_BYTE_ORDER == 1234)
143#define SWAP_DONE
144 for (i = 0; i < 16; ++i)
145 {
146 const Sha1::LONG T = *((Sha1::LONG *) dp);
147 dp += 4;
148 W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
149 ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
150 }
151#endif // SHA_BYTE_ORDER == 1234
152
153#if (SHA_BYTE_ORDER == 4321)
154#define SWAP_DONE
155 for (i = 0; i < 16; ++i)
156 {
157 const Sha1::LONG T = *((Sha1::LONG *) dp);
158 dp += 4;
159 W[i] = T32(T);
160 }
161#endif // SHA_BYTE_ORDER == 4321
162
163#if (SHA_BYTE_ORDER == 12345678)
164#define SWAP_DONE
165 for (i = 0; i < 16; i += 2)
166 {
167 Sha1::LONG T = *((Sha1::LONG *) dp);
168 dp += 8;
169 W[i] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
170 ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
171 T >>= 32;
172 W[i + 1] = ((T << 24) & 0xff000000) | ((T << 8) & 0x00ff0000) |
173 ((T >> 8) & 0x0000ff00) | ((T >> 24) & 0x000000ff);
174 }
175#endif // SHA_BYTE_ORDER == 12345678
176
177#if (SHA_BYTE_ORDER == 87654321)
178#define SWAP_DONE
179 for (i = 0; i < 16; i += 2)
180 {
181 const Sha1::LONG T = *((Sha1::LONG *) dp);
182 dp += 8;
183 W[i] = T32(T >> 32);
184 W[i + 1] = T32(T);

Callers 2

sha_updateFunction · 0.85
sha_finalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected