(byte[] source)
| 691 | |
| 692 | |
| 693 | private RSAPrivateCrtKeySpec parsePKCS1(byte[] source) { |
| 694 | Asn1Parser p = new Asn1Parser(source); |
| 695 | |
| 696 | // https://en.wikipedia.org/wiki/X.690#BER_encoding |
| 697 | // https://tools.ietf.org/html/rfc8017#page-55 |
| 698 | |
| 699 | // Type (sequence) |
| 700 | p.parseTag(0x30); |
| 701 | // Length |
| 702 | p.parseFullLength(); |
| 703 | |
| 704 | BigInteger version = p.parseInt(); |
| 705 | if (version.intValue() == 1) { |
| 706 | // JRE doesn't provide a suitable constructor for multi-prime |
| 707 | // keys |
| 708 | throw new IllegalArgumentException(sm.getString("pemFile.noMultiPrimes")); |
| 709 | } |
| 710 | return new RSAPrivateCrtKeySpec(p.parseInt(), p.parseInt(), p.parseInt(), p.parseInt(), p.parseInt(), |
| 711 | p.parseInt(), p.parseInt(), p.parseInt()); |
| 712 | } |
| 713 | |
| 714 | |
| 715 | private byte[] fromHex(String hexString) { |
no test coverage detected