* based on public domain SHA-1 code by Steve Reid <steve@edmweb.com>
* and on BSD-licensed SHA-2 code by Aaron D. Gifford
*
- * This file is part of FFmpeg.
+ * This file is part of Libav.
*
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "avutil.h"
#include "bswap.h"
#include "sha.h"
-#include "sha1.h"
#include "intreadwrite.h"
/** hash context */
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
-#define blk0(i) (block[i] = be2ne_32(((const uint32_t*)buffer)[i]))
+#define blk0(i) (block[i] = AV_RB32(buffer + 4 * (i)))
#define blk(i) (block[i] = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1))
#define R0(v,w,x,y,z,i) z += ((w&(x^y))^y) + blk0(i) + 0x5A827999 + rol(v, 5); w = rol(w, 30);
for (i = 0; i < 80; i++) {
int t;
if (i < 16)
- t = be2ne_32(((uint32_t*)buffer)[i]);
+ t = AV_RB32(buffer + 4 * i);
else
t = rol(block[i-3] ^ block[i-8] ^ block[i-14] ^ block[i-16], 1);
block[i] = t;
{
unsigned int i, a, b, c, d, e, f, g, h;
uint32_t block[64];
- uint32_t T1, av_unused(T2);
+ uint32_t T1;
a = state[0];
b = state[1];
h = state[7];
#if CONFIG_SMALL
for (i = 0; i < 64; i++) {
+ uint32_t T2;
if (i < 16)
T1 = blk0(i);
else
void av_sha_final(AVSHA* ctx, uint8_t *digest)
{
int i;
- uint64_t finalcount = be2ne_64(ctx->count << 3);
+ uint64_t finalcount = av_be2ne64(ctx->count << 3);
av_sha_update(ctx, "\200", 1);
while ((ctx->count & 63) != 56)
AV_WB32(digest + i*4, ctx->state[i]);
}
-#if LIBAVUTIL_VERSION_MAJOR < 51
-struct AVSHA1 {
- AVSHA sha;
-};
-
-const int av_sha1_size = sizeof(struct AVSHA1);
-
-void av_sha1_init(struct AVSHA1* context)
-{
- av_sha_init(&context->sha, 160);
-}
-
-void av_sha1_update(struct AVSHA1* context, const uint8_t* data, unsigned int len)
-{
- av_sha_update(&context->sha, data, len);
-}
-
-void av_sha1_final(struct AVSHA1* context, uint8_t digest[20])
-{
- av_sha_final(&context->sha, digest);
-}
-#endif
-
#ifdef TEST
#include <stdio.h>
#undef printf