- // BYTE privateExponent[rsapubkey.bitlen/8];
- rsap.D = new byte [byteLen];
- Array.Copy (blob, pos, rsap.D, 0, byteLen);
- Array.Reverse (rsap.D);
+ // ok, this is hackish but CryptoAPI support it so...
+ // note: only works because CRT is used by default
+ // http://bugzilla.ximian.com/show_bug.cgi?id=57941
+ rsap.D = new byte [byteLen]; // must be allocated
+ if (pos + byteLen + offset <= blob.Length) {
+ // BYTE privateExponent[rsapubkey.bitlen/8];
+ Buffer.BlockCopy (blob, pos, rsap.D, 0, byteLen);
+ Array.Reverse (rsap.D);
+ }