LibreOffice Module svl (master) 1
sigstruct.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_XMLSECURITY_INC_SIGSTRUCT_HXX
21#define INCLUDED_XMLSECURITY_INC_SIGSTRUCT_HXX
22
23#include <rtl/ustring.hxx>
24#include <com/sun/star/util/DateTime.hpp>
25#include <com/sun/star/xml/crypto/SecurityOperationStatus.hpp>
26#include <com/sun/star/xml/crypto/DigestID.hpp>
27#include <com/sun/star/uno/Sequence.hxx>
28
29#include <set>
30#include <vector>
31
32namespace com::sun::star::graphic { class XGraphic; }
33
34/*
35 * type of reference
36 */
38{
39 SAMEDOCUMENT = 1,
40 BINARYSTREAM = 2,
41 XMLSTREAM = 3
42};
43
45{
47 OUString ouURI;
48 // For ODF: XAdES digests (SHA256) or the old SHA1, from css::xml::crypto::DigestID
49 sal_Int32 nDigestID;
50 OUString ouDigestValue;
52 OUString ouType;
53
56 ouURI(""),
57 nDigestID(css::xml::crypto::DigestID::SHA1),
59 {
60 }
61
62 SignatureReferenceInformation( SignatureReferenceType type, sal_Int32 digestID, const OUString& uri, const OUString& rType ) :
64 {
65 nType = type;
66 nDigestID = digestID;
67 ouURI = uri;
68 ouType = rType;
69 }
70};
71
72typedef ::std::vector< SignatureReferenceInformation > SignatureReferenceInformations;
73
74namespace svl::crypto
75{
78{
79 RSA,
80 ECDSA
81};
82}
83
84
86{
87 sal_Int32 nSecurityId;
88 css::xml::crypto::SecurityOperationStatus nStatus;
91 {
96 OUString CertDigest;
98 OUString X509Subject;
99 };
100 typedef std::vector<X509CertInfo> X509Data;
101 // note: at parse time, it's unknown which one is the signing certificate;
102 // ImplVerifySignatures() figures it out and puts it at the back
103 std::vector<X509Data> X509Datas;
104
106 {
107 if (X509Datas.empty())
108 {
109 return nullptr;
110 }
111 assert(!X509Datas.back().empty());
112 return & X509Datas.back().back();
113 }
114
115 OUString ouGpgKeyID;
117 OUString ouGpgOwner;
118
120 css::util::DateTime stDateTime;
121
122 // XAdES EncapsulatedX509Certificate values
124
126 // signature may contain multiple time stamps - check they're consistent
128 //We also keep the date and time as string. This is done when this
129 //structure is created as a result of a XML signature being read.
130 //When then a signature is added or another removed, then the original
131 //XML signatures are written again (unless they have been removed).
132 //If the date time string is converted into the DateTime structure
133 //then information can be lost because it only holds a fractional
134 //of a second with an accuracy of one hundredth of second.
135 //If the string contains
136 //milliseconds (because the document was created by an application other than OOo)
137 //and the converted time is written back, then the string looks different
138 //and the signature is broken.
139 OUString ouDateTime;
147 css::uno::Reference<css::graphic::XGraphic> aValidSignatureImage;
148 css::uno::Reference<css::graphic::XGraphic> aInvalidSignatureImage;
152 css::uno::Sequence<sal_Int8> aSignatureBytes;
154 sal_Int32 nDigestID;
159
161
162 SignatureInformation( sal_Int32 nId )
163 {
165 nStatus = css::xml::crypto::SecurityOperationStatus_UNKNOWN;
166 nDigestID = 0;
170 }
171};
172
173typedef ::std::vector< SignatureInformation > SignatureInformations;
174
175#endif
176
177/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SignatureMethodAlgorithm
Specifies the algorithm used for signature generation and validation.
Definition: sigstruct.hxx:78
sal_Int16 nId
::std::vector< SignatureReferenceInformation > SignatureReferenceInformations
Definition: sigstruct.hxx:72
::std::vector< SignatureInformation > SignatureInformations
Definition: sigstruct.hxx:173
SignatureReferenceType
Definition: sigstruct.hxx:38
OUString CertDigest
OOXML certificate SHA-256 digest, empty for ODF except when doing XAdES signature.
Definition: sigstruct.hxx:96
OUString X509Subject
The certificate owner (aka subject).
Definition: sigstruct.hxx:98
css::uno::Reference< css::graphic::XGraphic > aValidSignatureImage
Valid and invalid signature line images.
Definition: sigstruct.hxx:147
SignatureReferenceInformations vSignatureReferenceInfors
Definition: sigstruct.hxx:89
OUString ouGpgCertificate
Definition: sigstruct.hxx:116
css::xml::crypto::SecurityOperationStatus nStatus
Definition: sigstruct.hxx:88
bool bPartialDocumentSignature
For PDF: the byte range doesn't cover the whole document.
Definition: sigstruct.hxx:158
bool bHasSigningCertificate
For PDF: has id-aa-signingCertificateV2 as a signed attribute.
Definition: sigstruct.hxx:156
OUString ouSignatureLineId
Signature Line Id, used to map signatures to their respective signature line images.
Definition: sigstruct.hxx:150
std::vector< X509Data > X509Datas
Definition: sigstruct.hxx:103
OUString ouDateTimePropertyId
The Id attribute of the <SignatureProperty> element that contains the <dc:date>.
Definition: sigstruct.hxx:141
SignatureInformation(sal_Int32 nId)
Definition: sigstruct.hxx:162
svl::crypto::SignatureMethodAlgorithm eAlgorithmID
Definition: sigstruct.hxx:160
std::set< OUString > maEncapsulatedX509Certificates
Definition: sigstruct.hxx:123
sal_Int32 nSecurityId
Definition: sigstruct.hxx:87
OUString ouDescription
Characters of the <dc:description> element inside the signature.
Definition: sigstruct.hxx:143
OUString ouDescriptionPropertyId
The Id attribute of the <SignatureProperty> element that contains the <dc:description>.
Definition: sigstruct.hxx:145
OUString ouSignatureValue
Definition: sigstruct.hxx:119
X509CertInfo const * GetSigningCertificate() const
Definition: sigstruct.hxx:105
sal_Int32 nDigestID
For PDF: digest format, from css::xml::crypto::DigestID.
Definition: sigstruct.hxx:154
std::vector< X509CertInfo > X509Data
Definition: sigstruct.hxx:100
css::uno::Sequence< sal_Int8 > aSignatureBytes
A full OOXML signature for unchanged roundtrip, empty for ODF.
Definition: sigstruct.hxx:152
css::uno::Reference< css::graphic::XGraphic > aInvalidSignatureImage
Definition: sigstruct.hxx:148
css::util::DateTime stDateTime
Definition: sigstruct.hxx:120
SignatureReferenceInformation(SignatureReferenceType type, sal_Int32 digestID, const OUString &uri, const OUString &rType)
Definition: sigstruct.hxx:62
OUString ouType
Type of the reference: a URI (newer idSignedProperties references) or empty.
Definition: sigstruct.hxx:52
SignatureReferenceType nType
Definition: sigstruct.hxx:46
ResultType type