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