client-cpp  0.10.0
RsaEncoderDecoder.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2016 CyberVision, Inc.
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 #ifndef RSAENCODERDECODER_HPP_
18 #define RSAENCODERDECODER_HPP_
19 
23 #include <botan/rsa.h>
24 #include <botan/cipher_mode.h>
25 #include <cstdint>
26 #include <memory>
27 
28 namespace kaa {
29 
31 public:
32  RsaEncoderDecoder(const PublicKey& pubKey,
33  const PrivateKey& privKey,
34  const PublicKey& remoteKey,
35  IKaaClientContext &context);
37 
39  virtual std::string encodeData(const std::uint8_t *data, std::size_t size);
40  virtual std::string decodeData(const std::uint8_t *data, std::size_t size);
41  virtual Signature signData(const std::uint8_t *data, std::size_t size);
42  virtual bool verifySignature(const std::uint8_t *data, std::size_t len, const std::uint8_t *sig, std::size_t sigLen);
43 
44 private:
45  std::string cipherPipe(const std::uint8_t *data, std::size_t size, Botan::Cipher_Dir dir);
46 
47 private:
48  Botan::AutoSeeded_RNG rng_;
49  std::unique_ptr<Botan::X509_PublicKey> pubKey_;
50  std::unique_ptr<Botan::PKCS8_PrivateKey> privKey_;
51  std::unique_ptr<Botan::X509_PublicKey> remoteKey_;
52 
53  SessionKey sessionKey_;
54 
55  IKaaClientContext &context_;
56 };
57 
58 }
59 
60 
61 #endif /* RSAENCODERDECODER_HPP_ */
Botan::secure_vector< std::uint8_t > PublicKey
Botan::SymmetricKey SessionKey
virtual Signature signData(const std::uint8_t *data, std::size_t size)
Botan::secure_vector< std::uint8_t > Signature
virtual std::string decodeData(const std::uint8_t *data, std::size_t size)
virtual EncodedSessionKey getEncodedSessionKey()
RsaEncoderDecoder(const PublicKey &pubKey, const PrivateKey &privKey, const PublicKey &remoteKey, IKaaClientContext &context)
virtual std::string encodeData(const std::uint8_t *data, std::size_t size)
virtual bool verifySignature(const std::uint8_t *data, std::size_t len, const std::uint8_t *sig, std::size_t sigLen)
Botan::secure_vector< std::uint8_t > EncodedSessionKey
std::string PrivateKey