1/* 2 * Copyright 2015 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 17package com.android.org.conscrypt; 18 19import java.security.cert.CertificateEncodingException; 20import java.security.cert.CertificateException; 21import javax.net.ssl.SSLException; 22 23class NativeCrypto { 24 public interface SSLHandshakeCallbacks { 25 /** 26 * Verify that we trust the certificate chain is trusted. 27 * 28 * @param asn1DerEncodedCertificateChain A chain of ASN.1 DER encoded certificates 29 * @param authMethod auth algorithm name 30 * 31 * @throws CertificateException if the certificate is untrusted 32 */ 33 public void verifyCertificateChain(byte[][] asn1DerEncodedCertificateChain, String authMethod) 34 throws CertificateException; 35 /** 36 * Called on an SSL client when the server requests (or 37 * requires a certificate). The client can respond by using 38 * SSL_use_certificate and SSL_use_PrivateKey to set a 39 * certificate if has an appropriate one available, similar to 40 * how the server provides its certificate. 41 * 42 * @param keyTypes key types supported by the server, 43 * convertible to strings with #keyType 44 * @param asn1DerEncodedX500Principals CAs known to the server 45 */ 46 public void clientCertificateRequested(byte[] keyTypes, 47 byte[][] asn1DerEncodedX500Principals) 48 throws CertificateEncodingException, SSLException; 49 /** 50 * Called when SSL handshake is completed. Note that this can 51 * be after SSL_do_handshake returns when handshake cutthrough 52 * is enabled. 53 */ 54 public void handshakeCompleted(); 55 } 56} 57