forked from libgit2/libgit2sharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCertificateSsh.cs
More file actions
67 lines (57 loc) · 1.86 KB
/
CertificateSsh.cs
File metadata and controls
67 lines (57 loc) · 1.86 KB
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
using System;
using System.Runtime.InteropServices;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
{
/// <summary>
/// This class represents the hostkey which is avaiable when connecting to a SSH host.
/// </summary>
public class CertificateSsh : Certificate
{
/// <summary>
/// For mocking purposes
/// </summary>
protected CertificateSsh()
{ }
/// <summary>
/// The MD5 hash of the host. Meaningful if <see cref="HasMD5"/> is true
/// </summary>
public readonly byte[] HashMD5;
/// <summary>
/// The SHA1 hash of the host. Meaningful if <see cref="HasSHA1"/> is true
/// </summary>
public readonly byte[] HashSHA1;
/// <summary>
/// True if we have the MD5 hostkey hash from the server
/// </summary>
public readonly bool HasMD5;
/// <summary>
/// True if we have the SHA1 hostkey hash from the server
/// </summary>
public readonly bool HasSHA1;
/// <summary>
/// True if we have the SHA1 hostkey hash from the server
/// </summary>public readonly bool HasSHA1;
internal unsafe CertificateSsh(git_certificate_ssh* cert)
{
HasMD5 = cert->type.HasFlag(GitCertificateSshType.MD5);
HasSHA1 = cert->type.HasFlag(GitCertificateSshType.SHA1);
HashMD5 = new byte[16];
fixed (byte* p = &HashMD5[0])
{
for (var i = 0; i < HashMD5.Length; i++)
{
HashMD5[i] = p[i];
}
}
HashSHA1 = new byte[20];
fixed (byte* p = &HashSHA1[0])
{
for (var i = 0; i < HashSHA1.Length; i++)
{
HashMD5[i] = p[i];
}
}
}
}
}