Blame libglusterfs/src/checksum.c
|
Packit Service |
e080da |
/*
|
|
Packit Service |
e080da |
Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
|
|
Packit Service |
e080da |
This file is part of GlusterFS.
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
This file is licensed to you under your choice of the GNU Lesser
|
|
Packit Service |
e080da |
General Public License, version 3 or any later version (LGPLv3 or
|
|
Packit Service |
e080da |
later), or the GNU General Public License, version 2 (GPLv2), in all
|
|
Packit Service |
e080da |
cases as published by the Free Software Foundation.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
#include <openssl/md5.h>
|
|
Packit Service |
e080da |
#include <openssl/sha.h>
|
|
Packit Service |
e080da |
#include <zlib.h>
|
|
Packit Service |
e080da |
#include <stdint.h>
|
|
Packit Service |
e080da |
#include <string.h>
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
/*
|
|
Packit Service |
e080da |
* The "weak" checksum required for the rsync algorithm.
|
|
Packit Service |
e080da |
*
|
|
Packit Service |
e080da |
* Note: these functions are only called to compute checksums on
|
|
Packit Service |
e080da |
* pathnames; they don't need to handle arbitrarily long strings of
|
|
Packit Service |
e080da |
* data. Thus int32_t and uint32_t are sufficient
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
uint32_t
|
|
Packit Service |
e080da |
gf_rsync_weak_checksum(unsigned char *buf, size_t len)
|
|
Packit Service |
e080da |
{
|
|
Packit Service |
e080da |
return adler32(0, buf, len);
|
|
Packit Service |
e080da |
}
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
/*
|
|
Packit Service |
e080da |
* The "strong" checksum required for the rsync algorithm.
|
|
Packit Service |
e080da |
*/
|
|
Packit Service |
e080da |
void
|
|
Packit Service |
e080da |
gf_rsync_strong_checksum(unsigned char *data, size_t len,
|
|
Packit Service |
e080da |
unsigned char *sha256_md)
|
|
Packit Service |
e080da |
{
|
|
Packit Service |
e080da |
SHA256((const unsigned char *)data, len, sha256_md);
|
|
Packit Service |
e080da |
}
|
|
Packit Service |
e080da |
|
|
Packit Service |
e080da |
void
|
|
Packit Service |
e080da |
gf_rsync_md5_checksum(unsigned char *data, size_t len, unsigned char *md5)
|
|
Packit Service |
e080da |
{
|
|
Packit Service |
e080da |
MD5(data, len, md5);
|
|
Packit Service |
e080da |
}
|