]>
git.saurik.com Git - apt.git/blob - apt-pkg/contrib/sha2.cc
2 * Cryptographic API. {{{
4 * SHA-512, as specified in
5 * http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 2 of the License, or (at your option)
15 #pragma implementation "apt-pkg/sha2.h"
18 #include <apt-pkg/sha2.h>
19 #include <apt-pkg/strutl.h>
21 // SHA2Summation::AddFD - Add content of file into the checksum /*{{{*/
22 // ---------------------------------------------------------------------
24 bool SHA2SummationBase::AddFD(int Fd
,unsigned long Size
){
25 unsigned char Buf
[64 * 64];
27 int ToEOF
= (Size
== 0);
28 while (Size
!= 0 || ToEOF
)
30 unsigned n
= sizeof(Buf
);
31 if (!ToEOF
) n
= min(Size
,(unsigned long)n
);
33 if (Res
< 0 || (!ToEOF
&& (unsigned) Res
!= n
)) // error, or short read
35 if (ToEOF
&& Res
== 0) // EOF