private static void DEREncodeVector(byte[] vector, int idx1, int length, byte[] output, int idx2)
{
if (length < 128) {
output[idx2++] = (byte) length;
} else if (length < 256) {
output[idx2++] = 0x81;
output[idx2++] = (byte) length;
} else {
output[idx2++] = 0x82;
output[idx2++] = (byte) (length >> 8);
output[idx2++] = (byte) (length);
}
Buffer.BlockCopy(vector, idx1, output, idx2, length);
}