diff options
Diffstat (limited to '')
-rw-r--r-- | CPP/Common/Sha256Reg.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/CPP/Common/Sha256Reg.cpp b/CPP/Common/Sha256Reg.cpp index 5f3a35b..b5689c4 100644 --- a/CPP/Common/Sha256Reg.cpp +++ b/CPP/Common/Sha256Reg.cpp | |||
@@ -9,13 +9,14 @@ | |||
9 | 9 | ||
10 | #include "../7zip/Common/RegisterCodec.h" | 10 | #include "../7zip/Common/RegisterCodec.h" |
11 | 11 | ||
12 | class CSha256Hasher: | 12 | Z7_CLASS_IMP_COM_2( |
13 | public IHasher, | 13 | CSha256Hasher |
14 | public ICompressSetCoderProperties, | 14 | , IHasher |
15 | public CMyUnknownImp | 15 | , ICompressSetCoderProperties |
16 | { | 16 | ) |
17 | CAlignedBuffer _buf; | 17 | CAlignedBuffer1 _buf; |
18 | Byte mtDummy[1 << 7]; | 18 | public: |
19 | Byte _mtDummy[1 << 7]; | ||
19 | 20 | ||
20 | CSha256 *Sha() { return (CSha256 *)(void *)(Byte *)_buf; } | 21 | CSha256 *Sha() { return (CSha256 *)(void *)(Byte *)_buf; } |
21 | public: | 22 | public: |
@@ -25,36 +26,32 @@ public: | |||
25 | Sha256_SetFunction(Sha(), 0); | 26 | Sha256_SetFunction(Sha(), 0); |
26 | Sha256_InitState(Sha()); | 27 | Sha256_InitState(Sha()); |
27 | } | 28 | } |
28 | |||
29 | MY_UNKNOWN_IMP2(IHasher, ICompressSetCoderProperties) | ||
30 | INTERFACE_IHasher(;) | ||
31 | STDMETHOD(SetCoderProperties)(const PROPID *propIDs, const PROPVARIANT *props, UInt32 numProps); | ||
32 | }; | 29 | }; |
33 | 30 | ||
34 | STDMETHODIMP_(void) CSha256Hasher::Init() throw() | 31 | Z7_COM7F_IMF2(void, CSha256Hasher::Init()) |
35 | { | 32 | { |
36 | Sha256_InitState(Sha()); | 33 | Sha256_InitState(Sha()); |
37 | } | 34 | } |
38 | 35 | ||
39 | STDMETHODIMP_(void) CSha256Hasher::Update(const void *data, UInt32 size) throw() | 36 | Z7_COM7F_IMF2(void, CSha256Hasher::Update(const void *data, UInt32 size)) |
40 | { | 37 | { |
41 | Sha256_Update(Sha(), (const Byte *)data, size); | 38 | Sha256_Update(Sha(), (const Byte *)data, size); |
42 | } | 39 | } |
43 | 40 | ||
44 | STDMETHODIMP_(void) CSha256Hasher::Final(Byte *digest) throw() | 41 | Z7_COM7F_IMF2(void, CSha256Hasher::Final(Byte *digest)) |
45 | { | 42 | { |
46 | Sha256_Final(Sha(), digest); | 43 | Sha256_Final(Sha(), digest); |
47 | } | 44 | } |
48 | 45 | ||
49 | 46 | ||
50 | STDMETHODIMP CSha256Hasher::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *coderProps, UInt32 numProps) | 47 | Z7_COM7F_IMF(CSha256Hasher::SetCoderProperties(const PROPID *propIDs, const PROPVARIANT *coderProps, UInt32 numProps)) |
51 | { | 48 | { |
52 | unsigned algo = 0; | 49 | unsigned algo = 0; |
53 | for (UInt32 i = 0; i < numProps; i++) | 50 | for (UInt32 i = 0; i < numProps; i++) |
54 | { | 51 | { |
55 | const PROPVARIANT &prop = coderProps[i]; | ||
56 | if (propIDs[i] == NCoderPropID::kDefaultProp) | 52 | if (propIDs[i] == NCoderPropID::kDefaultProp) |
57 | { | 53 | { |
54 | const PROPVARIANT &prop = coderProps[i]; | ||
58 | if (prop.vt != VT_UI4) | 55 | if (prop.vt != VT_UI4) |
59 | return E_INVALIDARG; | 56 | return E_INVALIDARG; |
60 | if (prop.ulVal > 2) | 57 | if (prop.ulVal > 2) |