1 // Copyright 2012 Google Inc. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef POLO_PAIRING_POLOCHALLENGERESPONSE_H_ 16 #define POLO_PAIRING_POLOCHALLENGERESPONSE_H_ 17 18 #include <openssl/x509v3.h> 19 #include <openssl/ssl.h> 20 #include <stdint.h> 21 #include <vector> 22 #include "polo/util/macros.h" 23 24 namespace polo { 25 namespace pairing { 26 27 typedef std::vector<uint8_t> Alpha, Gamma, Nonce; 28 29 // A Polo challenge response that contains the certificate keys. 30 class PoloChallengeResponse { 31 public: 32 // Creates a new challenge response with the given certificates. This does not 33 // take ownership of the given pointers. 34 // @param client_cert the client certificate 35 // @param server_cert the server certificate 36 PoloChallengeResponse(X509* client_cert, X509* server_cert); 37 ~PoloChallengeResponse()38 virtual ~PoloChallengeResponse() {} 39 40 // Computes the alpha value based on the given nonce. 41 virtual Alpha* GetAlpha(const Nonce& nonce) const; 42 43 // Computes the gamma value based on the given nonce. 44 virtual Gamma* GetGamma(const Nonce& nonce) const; 45 46 // Extracts the nonce from the given gamma value. 47 virtual Nonce* ExtractNonce(const Gamma& gamma) const; 48 49 // Verifies that the given gamma value is correct. 50 virtual bool CheckGamma(const Gamma& gamma) const; 51 private: 52 X509* client_cert; 53 X509* server_cert; 54 55 DISALLOW_COPY_AND_ASSIGN(PoloChallengeResponse); 56 }; 57 58 } // namespace pairing 59 } // namespace polo 60 61 #endif // POLO_PAIRING_POLOCHALLENGERESPONSE_H_ 62