Search in sources :

Example 1 with ClientRequestType

use of com.intel.mountwilson.ta.data.ClientRequestType in project OpenAttestation by OpenAttestation.

the class TrustAgentSecureClient method getAIKCertificate.

// XXX TODO  we need to return an X509Certificate here;   if the caller wants it in PEM format they can encode it.  returning a String is ambiguous and leaves open possibiility of parsing errors later. we should catch them here.
public String getAIKCertificate() {
    try {
        log.info("Sending Generate Identity");
        byte[] identityInput = "<identity_request></identity_request>".getBytes();
        this.data = identityInput;
        ClientRequestType response = sendQuoteRequest();
        String certificate = response.getAikcert();
        return certificate;
    } catch (ASException ase) {
        throw ase;
    } catch (UnknownHostException e) {
        throw new ASException(e, ErrorCode.AS_HOST_COMMUNICATION_ERROR, this.serverHostname);
    } catch (Exception e) {
        throw new ASException(e);
    }
}
Also used : UnknownHostException(java.net.UnknownHostException) ClientRequestType(com.intel.mountwilson.ta.data.ClientRequestType) ASException(com.intel.mountwilson.as.common.ASException) ASException(com.intel.mountwilson.as.common.ASException) PropertyException(javax.xml.bind.PropertyException) SocketTimeoutException(java.net.SocketTimeoutException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) JAXBException(javax.xml.bind.JAXBException) UnknownHostException(java.net.UnknownHostException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NoRouteToHostException(java.net.NoRouteToHostException)

Example 2 with ClientRequestType

use of com.intel.mountwilson.ta.data.ClientRequestType in project OpenAttestation by OpenAttestation.

the class TrustAgentSecureClient method getQuote.

public ClientRequestType getQuote(String nonce, String pcrList) throws PropertyException, JAXBException, UnknownHostException, IOException, KeyManagementException, NoSuchAlgorithmException {
    QuoteRequest quoteRequest = new QuoteRequest();
    quoteRequest.setPcrList(pcrList + ",22,22");
    quoteRequest.setNonce(nonce);
    this.data = getXml(quoteRequest).getBytes();
    ClientRequestType clientRequestType = sendQuoteRequest();
    log.info("Got quote from server");
    log.info("+++++++++++++++++++++++++++clientRequestType.getQuote(): " + clientRequestType.getQuote());
    log.info("+++++++++++++++++++++++++++clientRequestType.getEventLog(): " + new String(Base64.decodeBase64(clientRequestType.getEventLog())));
    return clientRequestType;
}
Also used : QuoteRequest(com.intel.mountwilson.ta.data.quoterequest.QuoteRequest) ClientRequestType(com.intel.mountwilson.ta.data.ClientRequestType)

Example 3 with ClientRequestType

use of com.intel.mountwilson.ta.data.ClientRequestType in project OpenAttestation by OpenAttestation.

the class TrustAgentSecureClient method sendQuoteRequest.

/**
     * 
     * @return an object representing the RESPONSE from the Trust Agent
     * @throws UnknownHostException if the IP address of the host could not be determined from local hosts file or DNS
     * @throws IOException if there was an error connecting to the host, such as it is not reachable on the network or it dropped the connection
     * @throws JAXBException when the response from the host cannot be interpreted properly
     * @throws NoSuchAlgorithmException 
     * @throws KeyManagementException 
     */
public synchronized ClientRequestType sendQuoteRequest() throws UnknownHostException, IOException, JAXBException, KeyManagementException, NoSuchAlgorithmException {
    try {
        byte[] buf = sendRequestWithSSLSocket();
        log.info("Unmarshalling to Jaxb object.");
        JAXBContext jc = JAXBContext.newInstance("com.intel.mountwilson.ta.data");
        assert jc != null;
        Unmarshaller u = jc.createUnmarshaller();
        assert u != null;
        assert new String(buf) != null;
        JAXBElement po = (JAXBElement) u.unmarshal(new StringReader(new String(buf).trim()));
        assert po != null;
        ClientRequestType response = (ClientRequestType) po.getValue();
        assert response != null;
        checkQuoteError(response);
        log.info("Done reading/writing to/from socket, closing socket.");
        return response;
    } finally {
    }
}
Also used : StringReader(java.io.StringReader) JAXBContext(javax.xml.bind.JAXBContext) JAXBElement(javax.xml.bind.JAXBElement) Unmarshaller(javax.xml.bind.Unmarshaller) ClientRequestType(com.intel.mountwilson.ta.data.ClientRequestType)

Example 4 with ClientRequestType

use of com.intel.mountwilson.ta.data.ClientRequestType in project OpenAttestation by OpenAttestation.

the class TAHelper method getQuoteInformationForHost.

public HashMap<String, PcrManifest> getQuoteInformationForHost(String hostname, TrustAgentSecureClient client, String pcrList) throws Exception {
    //  XXX BUG #497  START CODE SNIPPET MOVED TO INTEL HOST AGENT   
    String nonce = generateNonce();
    String sessionId = generateSessionId();
    ClientRequestType clientRequestType = client.getQuote(nonce, pcrList);
    log.info("got response from server [" + hostname + "] " + clientRequestType);
    String quote = clientRequestType.getQuote();
    log.info("extracted quote from response: " + quote);
    saveQuote(quote, sessionId);
    log.info("saved quote with session id: " + sessionId);
    // we only need to save the certificate when registring the host ... when we are just getting a quote we need to verify it using the previously saved AIK.
    if (trustedAik == null) {
        String aikCertificate = clientRequestType.getAikcert();
        log.info("extracted aik cert from response: " + aikCertificate);
        saveCertificate(aikCertificate, sessionId);
        log.info("saved host-provided AIK certificate with session id: " + sessionId);
    } else {
        // XXX we only need to save the certificate when registring the host ... when we are just getting a quote we don't need it            
        saveCertificate(trustedAik, sessionId);
        log.info("extracted aik cert from database: " + trustedAik);
        log.info("saved database-provided trusted AIK certificate with session id: " + sessionId);
    }
    saveNonce(nonce, sessionId);
    log.info("TAHelper - src: saved nonce with session id: " + sessionId);
    createRSAKeyFile(sessionId);
    log.info("created RSA key file for session id: " + sessionId);
    // issue #879
    byte[] eventLogBytes = Base64.decodeBase64(clientRequestType.getEventLog());
    HashMap<String, PcrManifest> pcrMap;
    if (eventLogBytes != null) {
        String decodedEventLog = new String(eventLogBytes);
        pcrMap = verifyQuoteAndGetPcr(sessionId, decodedEventLog);
        log.info("Got PCR map");
    } else {
        pcrMap = verifyQuoteAndGetPcr(sessionId, null);
        log.info("Got PCR map");
    }
    return pcrMap;
//log.log(Level.INFO, "PCR map = "+pcrMap); // need to untaint this first
}
Also used : PcrManifest(com.intel.mountwilson.manifest.data.PcrManifest) ClientRequestType(com.intel.mountwilson.ta.data.ClientRequestType)

Aggregations

ClientRequestType (com.intel.mountwilson.ta.data.ClientRequestType)4 ASException (com.intel.mountwilson.as.common.ASException)1 PcrManifest (com.intel.mountwilson.manifest.data.PcrManifest)1 QuoteRequest (com.intel.mountwilson.ta.data.quoterequest.QuoteRequest)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 MalformedURLException (java.net.MalformedURLException)1 NoRouteToHostException (java.net.NoRouteToHostException)1 SocketTimeoutException (java.net.SocketTimeoutException)1 UnknownHostException (java.net.UnknownHostException)1 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBElement (javax.xml.bind.JAXBElement)1 JAXBException (javax.xml.bind.JAXBException)1 PropertyException (javax.xml.bind.PropertyException)1 Unmarshaller (javax.xml.bind.Unmarshaller)1