RMS SDK for C++  0.2.1
A client library for using Microsoft RMS from Linux.
CryptoAPI.h
1 /*
2  * ======================================================================
3  * Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
4  * Licensed under the MIT License.
5  * See LICENSE.md in the project root for license information.
6  * ======================================================================
7 */
8 
9 #ifndef _RMS_CRYPTO_API_H_
10 #define _RMS_CRYPTO_API_H_
11 
12 #include <memory>
13 #include <vector>
14 #include "CryptoAPIExport.h"
15 #include "IStream.h"
16 #include "ICryptoProvider.h"
17 #include "ICryptoEngine.h"
18 
19 namespace rmscrypto {
20 namespace api {
21 // Stream factory
22 SharedStream DLL_PUBLIC_CRYPTO CreateCryptoStream(
23  CipherMode cipherMode,
24  const std::vector<uint8_t>& key,
25  SharedStream backingStream);
26 
27 // A random new key for current user will be generated at first time using
28 // keyInitializationData
29 // To reuse the same key you MUST put the same keyInitializationData as the
30 // first time
31 SharedStream DLL_PUBLIC_CRYPTO CreateCryptoStreamWithAutoKey(
32  CipherMode cipherMode,
33  const std::string& csKeyName,
34  SharedStream backingStream);
35 
36 std::shared_ptr<std::vector<uint8_t> >DLL_PUBLIC_CRYPTO EncryptWithAutoKey(
37  std::shared_ptr<std::vector<uint8_t> >pbIn,
38  CipherMode cipherMode = CIPHER_MODE_CBC4K,
39  const std::string & csKeyName = "default");
40 
41 std::shared_ptr<std::vector<uint8_t> >DLL_PUBLIC_CRYPTO DecryptWithAutoKey(
42  std::shared_ptr<std::vector<uint8_t> >pbIn,
43  CipherMode cipherMode = CIPHER_MODE_CBC4K,
44  const std::string & csKeyName = "default");
45 
46 SharedStream DLL_PUBLIC_CRYPTO CreateStreamFromStdStream(
47  std::shared_ptr<std::istream>stdIStream);
48 SharedStream DLL_PUBLIC_CRYPTO CreateStreamFromStdStream(
49  std::shared_ptr<std::ostream>stdOStream);
50 SharedStream DLL_PUBLIC_CRYPTO CreateStreamFromStdStream(
51  std::shared_ptr<std::iostream>stdIOStream);
52 
53 // create crypto primitives directly
54 std::shared_ptr<ICryptoProvider>DLL_PUBLIC_CRYPTO CreateCryptoProvider(
55  CipherMode cipherMode,
56  const std::vector<uint8_t>& key);
57 std::shared_ptr<ICryptoEngine>DLL_PUBLIC_CRYPTO CreateCryptoEngine();
58 } // namespace api
59 } // namespace rmscrypto
60 #endif // _RMS_CRYPTO_API_H_
Definition: BlockBasedProtectedStream.cpp:13