1 /* 2 * Copyright 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.conscrypt; 18 19 import java.io.InputStream; 20 import java.security.InvalidKeyException; 21 import java.security.NoSuchAlgorithmException; 22 import java.security.PublicKey; 23 24 /** 25 * Helper to initialize the JNI libraries. This version runs when compiled 26 * as part of the platform. 27 * 28 * @hide 29 */ 30 @Internal 31 public final class InternalUtil { logKeyToPublicKey(byte[] logKey)32 public static PublicKey logKeyToPublicKey(byte[] logKey) throws NoSuchAlgorithmException { 33 return new OpenSSLKey(NativeCrypto.EVP_parse_public_key(logKey)).getPublicKey(); 34 } 35 readPublicKeyPem(InputStream pem)36 public static PublicKey readPublicKeyPem(InputStream pem) throws InvalidKeyException, NoSuchAlgorithmException { 37 return OpenSSLKey.fromPublicKeyPemInputStream(pem).getPublicKey(); 38 } 39 getOcspSingleExtension( byte[] ocspResponse, String oid, long x509Ref, long issuerX509Ref)40 public static byte[] getOcspSingleExtension( 41 byte[] ocspResponse, String oid, long x509Ref, long issuerX509Ref) { 42 return NativeCrypto.get_ocsp_single_extension(ocspResponse, oid, x509Ref, issuerX509Ref); 43 } 44 InternalUtil()45 private InternalUtil() { 46 } 47 } 48