LibreOffice Module svl (master) 1
|
Helper to cryptographically sign and verify arbitrary data blocks. More...
#include <cryptosign.hxx>
Public Member Functions | |
Signing (css::uno::Reference< css::security::XCertificate > xCertificate) | |
void | AddDataRange (const void *pData, sal_Int32 size) |
Add a range to sign. More... | |
void | SetSignTSA (const OUString &tsa) |
void | SetSignPassword (const OUString &password) |
bool | Sign (OStringBuffer &rCMSHexBuffer) |
Signs one or more data blocks (as a single, contiguous, array). More... | |
Static Public Member Functions | |
static bool | Verify (const std::vector< unsigned char > &aData, const bool bNonDetached, const std::vector< unsigned char > &aSignature, SignatureInformation &rInformation) |
Verify and get Signature Information given a byte array. More... | |
static bool | Verify (SvStream &rStream, const std::vector< std::pair< size_t, size_t > > &aByteRanges, const bool bNonDetached, const std::vector< unsigned char > &aSignature, SignatureInformation &rInformation) |
Verify and get Signature Information given a signature and stream. More... | |
Private Attributes | |
const css::uno::Reference< css::security::XCertificate > | m_xCertificate |
The certificate to use for signing. More... | |
std::vector< std::pair< const void *, sal_Int32 > > | m_dataBlocks |
Data blocks (pointer-size pairs). More... | |
OUString | m_aSignTSA |
OUString | m_aSignPassword |
Helper to cryptographically sign and verify arbitrary data blocks.
Definition at line 48 of file cryptosign.hxx.
|
inline |
Definition at line 52 of file cryptosign.hxx.
|
inline |
Add a range to sign.
Note: for efficiency this takes a naked pointer, which must remain valid until this object is discarded.
Definition at line 60 of file cryptosign.hxx.
|
inline |
Definition at line 66 of file cryptosign.hxx.
|
inline |
Definition at line 65 of file cryptosign.hxx.
bool svl::crypto::Signing::Sign | ( | OStringBuffer & | rCMSHexBuffer | ) |
Signs one or more data blocks (as a single, contiguous, array).
Returns the signature (in PKCS#7 format) as string (hex).
Definition at line 942 of file cryptosign.cxx.
References aName, comphelper::Hash::calculateHash(), comphelper::Hash::finalize(), first, SvMemoryStream::GetData(), SvMemoryStream::GetSize(), i, last, m_aSignPassword, m_aSignTSA, m_dataBlocks, m_xCertificate, MAX_SIGNATURE_CONTENT_LENGTH, now, OUStringToOString(), pass, SAL_INFO, SAL_MAX_UINT32, SAL_WARN, comphelper::SHA256, TRUE, comphelper::rng::uniform_uint_distribution(), comphelper::Hash::update(), and values.
|
static |
Verify and get Signature Information given a byte array.
Definition at line 1911 of file cryptosign.cxx.
References aBuffer, aData, SignatureInformation::bHasSigningCertificate, CERT_NewTempCertificate, DateTime::ConvertToLocalTime(), DateTime::CreateFromUnixTime(), DateTime::CreateFromWin32FileDateTime(), comphelper::Base64::encode(), FALSE, Date::GetDay(), Date::GetMonth(), DateTime::GetUNODateTime(), Date::GetYear(), i, if(), SignatureInformation::nDigestID, SignatureInformation::nStatus, SignatureInformation::ouDateTime, SAL_WARN, comphelper::SHA1_HASH_LENGTH, comphelper::SHA256_HASH_LENGTH, comphelper::SHA512_HASH_LENGTH, SignatureInformation::stDateTime, TRUE, and SignatureInformation::X509Datas.
Referenced by Verify().
|
static |
Verify and get Signature Information given a signature and stream.
Definition at line 2346 of file cryptosign.cxx.
References SvStream::ReadBytes(), SvStream::Seek(), size, and Verify().
|
private |
Definition at line 92 of file cryptosign.hxx.
Referenced by Sign().
|
private |
Definition at line 91 of file cryptosign.hxx.
Referenced by Sign().
|
private |
Data blocks (pointer-size pairs).
Definition at line 90 of file cryptosign.hxx.
Referenced by Sign().
|
private |
The certificate to use for signing.
Definition at line 87 of file cryptosign.hxx.
Referenced by Sign().