Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / xmlsecurity / inc / sigstruct.hxx
blobff6ee5e5d3a552d5902bb80610b7696f9950b40d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_XMLSECURITY_INC_SIGSTRUCT_HXX
21 #define INCLUDED_XMLSECURITY_INC_SIGSTRUCT_HXX
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>
29 #include <set>
30 #include <vector>
33 * type of reference
35 enum class SignatureReferenceType
37 SAMEDOCUMENT = 1,
38 BINARYSTREAM = 2,
39 XMLSTREAM = 3
42 struct SignatureReferenceInformation
44 SignatureReferenceType nType;
45 OUString ouURI;
46 // For ODF: XAdES digests (SHA256) or the old SHA1, from css::xml::crypto::DigestID
47 sal_Int32 nDigestID;
48 OUString ouDigestValue;
50 SignatureReferenceInformation() :
51 nType(SignatureReferenceType::SAMEDOCUMENT),
52 ouURI(""),
53 nDigestID(css::xml::crypto::DigestID::SHA1),
54 ouDigestValue("")
58 SignatureReferenceInformation( SignatureReferenceType type, sal_Int32 digestID, const OUString& uri ) :
59 SignatureReferenceInformation()
61 nType = type;
62 nDigestID = digestID;
63 ouURI = uri;
67 typedef ::std::vector< SignatureReferenceInformation > SignatureReferenceInformations;
69 struct SignatureInformation
71 sal_Int32 nSecurityId;
72 css::xml::crypto::SecurityOperationStatus nStatus;
73 SignatureReferenceInformations vSignatureReferenceInfors;
74 OUString ouX509IssuerName;
75 OUString ouX509SerialNumber;
76 OUString ouX509Certificate;
78 OUString ouGpgKeyID;
79 OUString ouGpgCertificate;
80 OUString ouGpgOwner;
82 OUString ouSignatureValue;
83 css::util::DateTime stDateTime;
85 // XAdES EncapsulatedX509Certificate values
86 std::set<OUString> maEncapsulatedX509Certificates;
88 //We also keep the date and time as string. This is done when this
89 //structure is created as a result of a XML signature being read.
90 //When then a signature is added or another removed, then the original
91 //XML signatures are written again (unless they have been removed).
92 //If the date time string is converted into the DateTime structure
93 //then information can be lost because it only holds a fractional
94 //of a second with a accuracy of one hundredth of second.
95 //If the string contains
96 //milli seconds (because the document was created by an application other than OOo)
97 //and the converted time is written back, then the string looks different
98 //and the signature is broken.
99 OUString ouDateTime;
100 OUString ouSignatureId;
101 OUString ouPropertyId;
102 /// Characters of the <dc:description> element inside the signature.
103 OUString ouDescription;
104 /// The Id attribute of the <SignatureProperty> element that contains the <dc:description>.
105 OUString ouDescriptionPropertyId;
106 /// OOXML certificate SHA-256 digest, empty for ODF except when doing XAdES signature.
107 OUString ouCertDigest;
108 /// A full OOXML signature for unchanged roundtrip, empty for ODF.
109 css::uno::Sequence<sal_Int8> aSignatureBytes;
110 /// For PDF: digest format, from css::xml::crypto::DigestID
111 sal_Int32 nDigestID;
112 /// For PDF: has id-aa-signingCertificateV2 as a signed attribute.
113 bool bHasSigningCertificate;
114 /// For PDF: the byte range doesn't cover the whole document.
115 bool bPartialDocumentSignature;
117 SignatureInformation( sal_Int32 nId )
119 nSecurityId = nId;
120 nStatus = css::xml::crypto::SecurityOperationStatus_UNKNOWN;
121 nDigestID = 0;
122 bHasSigningCertificate = false;
123 bPartialDocumentSignature = false;
127 typedef ::std::vector< SignatureInformation > SignatureInformations;
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */