init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
using System;
namespace Org.BouncyCastle.Bcpg.OpenPgp;
public sealed class PgpPad
{
private PgpPad()
{
}
public static byte[] PadSessionData(byte[] sessionInfo)
{
byte[] array = new byte[40];
Array.Copy(sessionInfo, 0, array, 0, sessionInfo.Length);
byte b = (byte)(array.Length - sessionInfo.Length);
for (int i = sessionInfo.Length; i != array.Length; i++)
{
array[i] = b;
}
return array;
}
public static byte[] UnpadSessionData(byte[] encoded)
{
byte b = encoded[^1];
for (int i = encoded.Length - b; i != encoded.Length; i++)
{
if (encoded[i] != b)
{
throw new PgpException("bad padding found in session data");
}
}
byte[] array = new byte[encoded.Length - b];
Array.Copy(encoded, 0, array, 0, array.Length);
return array;
}
}