-
Notifications
You must be signed in to change notification settings - Fork 7
/
DigitalSignatureOutputStream.h
86 lines (76 loc) · 2.4 KB
/
DigitalSignatureOutputStream.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright (c) 2007-2009 Digital Bazaar, Inc. All rights reserved.
*/
#ifndef monarch_crypto_DigitalSignatureOutputStream_H
#define monarch_crypto_DigitalSignatureOutputStream_H
#include "monarch/io/FilterOutputStream.h"
#include "monarch/crypto/DigitalSignature.h"
namespace monarch
{
namespace crypto
{
/**
* A DigitalSignatureOutputStream is used to create or verify a digital
* signature on data written to an output stream.
*
* @author Dave Longley
*/
class DigitalSignatureOutputStream : public monarch::io::FilterOutputStream
{
protected:
/**
* The DigitalSignature to update.
*/
DigitalSignature* mSignature;
/**
* True to clean up the DigitalSignature when destructing, false not to.
*/
bool mCleanupSignature;
public:
/**
* Creates a new DigitalSignatureOutputStream that creates or verifies
* the given DigitalSignature on data filtered to the passed output
* stream.
*
* @param ds the DigitalSignature to use.
* @param cleanupSignature true to clean up the signature when destructing,
* false not to.
* @param os the underlying OutputStream to read from.
* @param cleanupStream true to clean up the passed OutputStream when
* destructing, false not to.
*/
DigitalSignatureOutputStream(
DigitalSignature* ds, bool cleanupSignature,
monarch::io::OutputStream* os, bool cleanupStream);
/**
* Destructs this DigitalSignatureOutputStream.
*/
virtual ~DigitalSignatureOutputStream();
/**
* Writes some bytes to the stream.
*
* @param b the array of bytes to write.
* @param length the number of bytes to write to the stream.
*
* @return true if the write was successful, false if an IO exception
* occurred.
*/
virtual bool write(const char* b, int length);
/**
* Sets the DigitalSignature associated with this stream.
*
* @param ds the DigitalSignature to associate with this stream.
* @param cleanup true to clean up the signature when destructing,
* false not to.
*/
virtual void setSignature(DigitalSignature* ds, bool cleanup);
/**
* Gets the DigitalSignature associated with this stream.
*
* @return the DigitalSignature associated with this stream.
*/
virtual DigitalSignature* getSignature();
};
} // end namespace crypto
} // end namespace monarch
#endif