blob: 59ad87a7b7a48469e070f36eb2b33c423d7f186d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
using System;
using Org.BouncyCastle.Crypto.Digests;
namespace Org.BouncyCastle.Crypto.Tls
{
/// <remarks>A combined hash, which implements md5(m) || sha1(m).</remarks>
internal class CombinedHash
: IDigest
{
private readonly MD5Digest md5;
private readonly Sha1Digest sha1;
internal CombinedHash()
{
this.md5 = new MD5Digest();
this.sha1 = new Sha1Digest();
}
internal CombinedHash(CombinedHash t)
{
this.md5 = new MD5Digest(t.md5);
this.sha1 = new Sha1Digest(t.sha1);
}
/// <seealso cref="IDigest.AlgorithmName"/>
public string AlgorithmName
{
get
{
return md5.AlgorithmName + " and " + sha1.AlgorithmName + " for TLS 1.0";
}
}
/// <seealso cref="IDigest.GetByteLength"/>
public int GetByteLength()
{
return System.Math.Max(md5.GetByteLength(), sha1.GetByteLength());
}
/// <seealso cref="IDigest.GetDigestSize"/>
public int GetDigestSize()
{
return md5.GetDigestSize() + sha1.GetDigestSize();
}
/// <seealso cref="IDigest.Update"/>
public void Update(
byte input)
{
md5.Update(input);
sha1.Update(input);
}
/// <seealso cref="IDigest.BlockUpdate"/>
public void BlockUpdate(
byte[] input,
int inOff,
int len)
{
md5.BlockUpdate(input, inOff, len);
sha1.BlockUpdate(input, inOff, len);
}
/// <seealso cref="IDigest.DoFinal"/>
public int DoFinal(
byte[] output,
int outOff)
{
int i1 = md5.DoFinal(output, outOff);
int i2 = sha1.DoFinal(output, outOff + i1);
return i1 + i2;
}
/// <seealso cref="IDigest.Reset"/>
public void Reset()
{
md5.Reset();
sha1.Reset();
}
}
}
|