Bump version to 6.4-15
[LibreOffice.git] / include / svl / sigstruct.hxx
blobf6ee242c84d16e4f351f1a9902e9b2d0dbc1e34d
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>
32 namespace com { namespace sun { namespace star { namespace graphic { class XGraphic; } } } }
35 * type of reference
37 enum class SignatureReferenceType
39 SAMEDOCUMENT = 1,
40 BINARYSTREAM = 2,
41 XMLSTREAM = 3
44 struct SignatureReferenceInformation
46 SignatureReferenceType nType;
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;
51 /// Type of the reference: a URI (newer idSignedProperties references) or empty.
52 OUString ouType;
54 SignatureReferenceInformation() :
55 nType(SignatureReferenceType::SAMEDOCUMENT),
56 ouURI(""),
57 nDigestID(css::xml::crypto::DigestID::SHA1),
58 ouDigestValue("")
62 SignatureReferenceInformation( SignatureReferenceType type, sal_Int32 digestID, const OUString& uri, const OUString& rType ) :
63 SignatureReferenceInformation()
65 nType = type;
66 nDigestID = digestID;
67 ouURI = uri;
68 ouType = rType;
72 typedef ::std::vector< SignatureReferenceInformation > SignatureReferenceInformations;
74 namespace svl
76 namespace crypto
78 /// Specifies the algorithm used for signature generation and validation.
79 enum class SignatureMethodAlgorithm
81 RSA,
82 ECDSA
87 struct SignatureInformation
89 sal_Int32 nSecurityId;
90 css::xml::crypto::SecurityOperationStatus nStatus;
91 SignatureReferenceInformations vSignatureReferenceInfors;
92 OUString ouX509IssuerName;
93 OUString ouX509SerialNumber;
94 OUString ouX509Certificate;
96 OUString ouGpgKeyID;
97 OUString ouGpgCertificate;
98 OUString ouGpgOwner;
100 OUString ouSignatureValue;
101 css::util::DateTime stDateTime;
103 // XAdES EncapsulatedX509Certificate values
104 std::set<OUString> maEncapsulatedX509Certificates;
106 //We also keep the date and time as string. This is done when this
107 //structure is created as a result of a XML signature being read.
108 //When then a signature is added or another removed, then the original
109 //XML signatures are written again (unless they have been removed).
110 //If the date time string is converted into the DateTime structure
111 //then information can be lost because it only holds a fractional
112 //of a second with an accuracy of one hundredth of second.
113 //If the string contains
114 //milliseconds (because the document was created by an application other than OOo)
115 //and the converted time is written back, then the string looks different
116 //and the signature is broken.
117 OUString ouDateTime;
118 OUString ouSignatureId;
119 OUString ouPropertyId;
120 /// Characters of the <dc:description> element inside the signature.
121 OUString ouDescription;
122 /// The Id attribute of the <SignatureProperty> element that contains the <dc:description>.
123 OUString ouDescriptionPropertyId;
124 /// OOXML certificate SHA-256 digest, empty for ODF except when doing XAdES signature.
125 OUString ouCertDigest;
126 /// Valid and invalid signature line images
127 css::uno::Reference<css::graphic::XGraphic> aValidSignatureImage;
128 css::uno::Reference<css::graphic::XGraphic> aInvalidSignatureImage;
129 /// Signature Line Id, used to map signatures to their respective signature line images.
130 OUString ouSignatureLineId;
131 /// A full OOXML signature for unchanged roundtrip, empty for ODF.
132 css::uno::Sequence<sal_Int8> aSignatureBytes;
133 /// For PDF: digest format, from css::xml::crypto::DigestID
134 sal_Int32 nDigestID;
135 /// For PDF: has id-aa-signingCertificateV2 as a signed attribute.
136 bool bHasSigningCertificate;
137 /// For PDF: the byte range doesn't cover the whole document.
138 bool bPartialDocumentSignature;
140 /// The certificate owner (aka subject).
141 OUString ouSubject;
143 svl::crypto::SignatureMethodAlgorithm eAlgorithmID;
145 SignatureInformation( sal_Int32 nId )
147 nSecurityId = nId;
148 nStatus = css::xml::crypto::SecurityOperationStatus_UNKNOWN;
149 nDigestID = 0;
150 bHasSigningCertificate = false;
151 bPartialDocumentSignature = false;
152 eAlgorithmID = svl::crypto::SignatureMethodAlgorithm::RSA;
156 typedef ::std::vector< SignatureInformation > SignatureInformations;
158 #endif
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */