| 47 | /// |
| 48 | /// - `format`: encoding format identifier ("RAW", "X.509", "PKCS#8") |
| 49 | protected Key(String algorithm, byte[] encoded, String format) { |
| 50 | if (algorithm == null) { |
| 51 | throw new CryptoException("algorithm must not be null"); |
| 52 | } |
| 53 | if (encoded == null) { |
| 54 | throw new CryptoException("encoded must not be null"); |
| 55 | } |
| 56 | this.algorithm = algorithm; |
| 57 | this.encoded = new byte[encoded.length]; |
| 58 | System.arraycopy(encoded, 0, this.encoded, 0, encoded.length); |
| 59 | this.format = format; |
| 60 | } |
| 61 | |
| 62 | /// Returns a fresh copy of the encoded key bytes. Treat returns from |
| 63 | /// private keys as sensitive material -- do not log or store |