apt @VERSION@
sha1.h
00001 // -*- mode: cpp; mode: fold -*-
00002 // Description                                                          /*{{{*/
00003 // $Id: sha1.h,v 1.3 2001/05/07 05:05:47 jgg Exp $
00004 /* ######################################################################
00005 
00006    SHA1SumValue - Storage for a SHA-1 hash.
00007    SHA1Summation - SHA-1 Secure Hash Algorithm.
00008    
00009    This is a C++ interface to a set of SHA1Sum functions, that mirrors
00010    the equivalent MD5 classes. 
00011 
00012    ##################################################################### */
00013                                                                         /*}}}*/
00014 #ifndef APTPKG_SHA1_H
00015 #define APTPKG_SHA1_H
00016 
00017 #include <string>
00018 #include <cstring>
00019 #include <algorithm>
00020 
00021 #include "hashsum_template.h"
00022 
00023 typedef  HashSumValue<160> SHA1SumValue;
00024 
00025 class SHA1Summation : public SummationImplementation
00026 {
00027    /* assumes 64-bit alignment just in case */
00028    unsigned char Buffer[64] __attribute__((aligned(8)));
00029    unsigned char State[5*4] __attribute__((aligned(8)));
00030    unsigned char Count[2*4] __attribute__((aligned(8)));
00031    bool Done;
00032    
00033    public:
00034    bool Add(const unsigned char *inbuf, unsigned long long inlen);
00035    using SummationImplementation::Add;
00036 
00037    SHA1SumValue Result();
00038    
00039    SHA1Summation();
00040 };
00041 
00042 #endif