-
Notifications
You must be signed in to change notification settings - Fork 768
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from CCob/master
Initial support for PKINIT TGT's
- Loading branch information
Showing
33 changed files
with
3,930 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
|
||
namespace Rubeus.Asn1 { | ||
public static class Asn1Extensions { | ||
|
||
public static byte[] DepadLeft(this byte[] data) { | ||
|
||
int leadingZeros = 0; | ||
for (var i = 0; i < data.Length; i++) { | ||
if (data[i] == 0) { | ||
leadingZeros++; | ||
} else { | ||
break; | ||
} | ||
} | ||
|
||
byte[] result = new byte[data.Length - leadingZeros]; | ||
Array.Copy(data, leadingZeros, result, 0, data.Length - leadingZeros); | ||
return result; | ||
} | ||
|
||
public static byte[] PadLeft(this byte[] data, int totalSize) { | ||
|
||
if(data.Length == totalSize) { | ||
return data; | ||
} | ||
|
||
if(totalSize < data.Length) { | ||
throw new ArgumentException("data bigger than totalSize, cannot pad with 0's"); | ||
} | ||
|
||
byte[] result = new byte[totalSize]; | ||
data.CopyTo(result, totalSize - data.Length); | ||
return result; | ||
} | ||
|
||
public static byte[] PadRight(this byte[] data, int length) { | ||
if (data.Length == length) { | ||
return data; | ||
} | ||
|
||
var copy = new byte[length]; | ||
data.CopyTo(copy, length - data.Length); | ||
return copy; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.