9 #ifndef _CRYPTO_STREAMS_LIB_PROTECTION_BLOCKBASEDPROTECTEDSTREAM_H_
10 #define _CRYPTO_STREAMS_LIB_PROTECTION_BLOCKBASEDPROTECTEDSTREAM_H_
13 #include "CryptoAPIExport.h"
15 #include "ICryptoProvider.h"
16 #include "SimpleProtectedStream.h"
17 #include "CachedBlock.h"
22 public std::enable_shared_from_this<
23 BlockBasedProtectedStream>{
26 static DLL_PUBLIC_CRYPTO std::shared_ptr<BlockBasedProtectedStream>Create(
27 std::shared_ptr<ICryptoProvider>pCryptoProvider,
28 std::shared_ptr<IStream> pBackingStream,
29 uint64_t u64ContentStart,
30 uint64_t u64ContentSize,
31 uint64_t u64BlockSize);
34 virtual std::shared_future<int64_t>ReadAsync(uint8_t *pbBuffer,
37 std::launch launchType)
39 virtual std::shared_future<int64_t>WriteAsync(
const uint8_t *cpbBuffer,
42 std::launch launchType)
44 virtual std::future<bool>FlushAsync(std::launch launchType)
override;
46 virtual int64_t Read(uint8_t *pbBuffer,
47 int64_t cbBuffer)
override;
48 virtual int64_t Write(
const uint8_t *cpbBuffer,
49 int64_t cbBuffer)
override;
50 virtual bool Flush()
override;
52 virtual SharedStream Clone()
override;
54 virtual void Seek(uint64_t u64Position)
override;
55 virtual bool CanRead()
const override;
56 virtual bool CanWrite()
const override;
57 virtual uint64_t Position()
override;
58 virtual uint64_t Size()
override;
59 virtual void Size(uint64_t u64Value)
override;
66 std::shared_ptr<ICryptoProvider>pCryptoProvider,
67 std::shared_ptr<IStream> pBackingStream,
68 uint64_t u64ContentStart,
69 uint64_t u64ContentSize,
70 uint64_t u64BlockSize);
72 void SeekInternal(uint64_t u64Position);
73 uint64_t PositionInner();
75 void SizeInner(uint64_t value);
76 bool CanWriteInner()
const;
77 std::shared_future<int64_t>WriteInternalAsync(
const uint8_t *cpbBuffer,
80 std::launch launchType,
83 void ProcessSizeChangeRequest();
84 void SizeInternal(uint64_t size);
85 void FillWithZeros(uint64_t newSize);
93 std::shared_ptr<std::mutex> m_locker;
95 std::shared_ptr<SimpleProtectedStream> m_pSimple;
96 std::shared_ptr<CachedBlock> m_pCachedBlock;
98 uint64_t m_u64Position;
99 bool m_bIsPositionValid;
100 uint64_t m_u64NewSize;
105 #endif // _CRYPTO_STREAMS_LIB_PROTECTION_BLOCKBASEDPROTECTEDSTREAM_H_
Definition: BlockBasedProtectedStream.cpp:13
Base interface for protected streams.
Definition: IStream.h:34
Definition: BlockBasedProtectedStream.h:21