/usr/include/xsec/dsig/DSIGKeyInfoX509.hpp is in libxml-security-c-dev 1.7.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/*
* XSEC
*
* DSIGKeyInfoX509 := A "Super" key that defines a certificate with a sub-key that defines
* the signing key
*
* $Id: DSIGKeyInfoX509.hpp 1125514 2011-05-20 19:08:33Z scantor $
*
*/
#ifndef DSIGKEYINFOX509_INCLUDE
#define DSIGKEYINFOX509_INCLUDE
#include <xsec/utils/XSECSafeBuffer.hpp>
#include <xsec/dsig/DSIGKeyInfo.hpp>
#include <xsec/enc/XSECCryptoX509.hpp>
#include <vector>
XSEC_USING_XERCES(DOMElement);
/**
* @ingroup pubsig
*/
/**
* @brief The class for \<X509Data\> nodes in a KeyInfo list.
*
* Class for holding information on a X509Data node as well as setting
* such a node in a signature.
*
*/
class DSIG_EXPORT DSIGKeyInfoX509 : public DSIGKeyInfo {
public:
struct X509Holder {
const XMLCh * mp_encodedX509; // Base64 encoding
XSECCryptoX509 * mp_cryptoX509; // The certificate
};
#if defined(XSEC_NO_NAMESPACES)
typedef vector<X509Holder *> X509ListType;
typedef vector<const XMLCh *> X509CRLListType;
#else
typedef std::vector<X509Holder *> X509ListType;
typedef std::vector<const XMLCh *> X509CRLListType;
#endif
#if defined(XSEC_SIZE_T_IN_NAMESPACE_STD)
typedef std::size_t size_type;
#else
typedef size_t size_type;
#endif
/** @name Constructors and Destructors */
//@{
/**
* \brief Constructor used when XML structures exist.
*
* Constructor called by interface class when loading an
* X509Data element from DOM nodes.
*
* @param env Operating environment
* @param X509Data DOMNode at start of data
*/
DSIGKeyInfoX509(const XSECEnv * env, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *X509Data);
/**
* \brief Constructor called when building XML structures
*
* Constructor called by interface class when an XML
* structure is being built by a user calling the API
*
* @param env Operating environment
*/
DSIGKeyInfoX509(const XSECEnv * env);
/**
* \brief Destructor
*/
virtual ~DSIGKeyInfoX509();
//@}
/** @name Load function and get methods */
//@{
/**
* \brief Function called to load an XML structure
*
* Function called by intercace class to load an X509Data structure
* from DOMNodes.
*/
virtual void load();
/**
* \brief Get the name of the certificate
*
* Get the name stored in the X509SubjectName element (if it
* exists).
*
* @returns A pointer to a buffer containing the name
* (NULL if not set.)
*/
const XMLCh * getX509SubjectName(void) const;
/**
* \brief Get the name of the certificate (interface function)
*
* Get the name stored in the X509SubjectName element (if it
* exists).
*
* @returns A pointer to the buffer containing the name (or NULL if not set).
* The decoded string is returned.
* @see setX509SubjectName(void)
*/
const XMLCh * getKeyName(void) const;
/**
* \brief Get the X509Digest Algorithm
*
* Get the Algorithm for the X509Digest.
*
* @returns A pointer to the buffer containing the algorithm
* (0 if not set.)
*/
const XMLCh* getX509DigestAlgorithm(void) const;
/**
* \brief Get the X509Digest value
*
* Get the value for the X509Digest.
*
* @returns A pointer to the buffer containing the digest
* (0 if not set.)
*/
const XMLCh* getX509DigestValue(void) const;
/**
* \brief Get the IssuerSerialName
*
* Get the name of the Issuer (stored in the X509IssuerSerial element).
*
* @returns A pointer to the buffer containing the issuer name.
* (0 if not set.)
*/
const XMLCh * getX509IssuerName(void) const;
/**
* \brief Get the IsserSerialNumber
*
* Get the serial number of the certificate of the issuer of the
* signing certificate.
*
* @returns A pointer to the string containing the IssuerSerialNumber.
* (0 if not set.) This is the decoded string.
* @see setX509IssuerSerial
*/
const XMLCh * getX509IssuerSerialNumber(void) const;
/**
* \brief Get the first associated CRL
*
* Return the string containing the base64 encoded CRL that was held in
* the first X509CRL node
*
* @returns A pointer to the string containing the CRL
* (0 if not set)
*/
const XMLCh * getX509CRL(void) const;
/**
* \brief Find the number of CRLs held
*
* Find the number of CRLs held in the X509Data structures.
*
* @returns The number of CRLs
*/
int getX509CRLListSize(void) const;
/**
* \brief Get the DER encoded CRL pointed to in the list.
*
* Use the index to find the required CRL and return a pointer
* to the buffer containing the encoded CRL.
*
* @returns A pointer to the buffer containing the CRL or 0 if
* no CRL exists at that point in the list.
*/
const XMLCh * getX509CRLItem(int item) const;
/**
* \brief Get the SKI value (if set)
*
* The SKI (Subject Key Identifier) can be used to reference a
* required certificate. If this was set in the KeyInfo element,
* this function will return the value
*
* @returns the base64 encoded (plan - not DER) encoded SKI value
*/
const XMLCh * getX509SKI(void) const;
/**
* \brief Return the raw Retrieval method to find this certificate
*
* In some cases, the KeyInfo RetrievalMethod references a raw certificate
* In such cases, the library simply creates a KeyInfoX509 object and sets
* this string to allow others to find the certificate
*/
const XMLCh * getRawRetrievalURI(void) const;
/**
* \brief Find the number of certificates held
*
* Find the number of certificates held in the X509Data structures.
*
* @returns The number of certificates
*/
int getCertificateListSize(void) const;
/**
* \brief Get the DER encoded certificate pointed to in the list.
*
* Use the index to find the required certificate and return a pointer
* to the buffer containing the encoded certificate.
*
* @returns A pointer to the buffer containing the certificate or 0 if
* no certificate exists at that point in the list.
*/
const XMLCh * getCertificateItem(int item) const;
/**
* \brief Get the Crypto Interface X509 structure version of the certificate
*
* Use the index to find the required certificate and return a pointer
* to the XSECCryptoX509 cert
*
* @returns A pointer to the XSECCryptoX509 cert structure
*/
XSECCryptoX509 * getCertificateCryptoItem(int item);
/**
* \brief Get the Crypto Interface X509 structure version of the certificate
*
* Use the index to find the required certificate and return a pointer
* to the XSECCryptoX509 cert
*
* @returns A pointer to the XSECCryptoX509 cert structure
*/
const XSECCryptoX509 * getCertificateCryptoItem(int item) const;
/**
* \brief Interface function to find the type of this KeyInfo
*/
virtual keyInfoType getKeyInfoType(void) const {return DSIGKeyInfo::KEYINFO_X509;}
//@}
/** @name Create and Set functions */
//@{
/**
* \brief Create a new X509 data element.
*
* Create a blank (empty) X509Data element that can then be used
* by the application to add X509Data elements.
*
* @returns A pointer to the new X509Data element.
*/
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *
createBlankX509Data(void);
/**
* \brief Set the X509SubjectName element in the KeyInfo element.
*
* If a X509SubjectName element exists, replace the text with the
* provided text. Otherwise create the element and set the text.
*
* @note XMLDSIG requires Distinguished Names be encoded in a defined
* manner (escaping '<' characters etc.). This method will perform
* this encoding prior to creating the DOM nodes.
*
* @param name The name to set.
*/
void setX509SubjectName(const XMLCh * name);
/**
* \brief Set the IssuerSerial element
*
* If an X509IssuerSerial exists, replace the values with those provided,
* otherwise create a new element and set the values appropriately.
*
* @note XMLDSIG requires Distinguished Names be encoded in a defined
* manner (escaping '<' characters etc.). This method will perform
* this encoding prior to creating the DOM nodes.
*
* @param name The name of the issuer.
* @param serial The serial number of the issuer's certificate
*/
void setX509IssuerSerial(const XMLCh * name, const XMLCh * serial);
/**
* \brief Set the dsig11:X509Digest element
*
* If a dsig11:X509Digest exists, replace the values with those provided,
* otherwise create a new element and set the values appropriately.
*
* @param algorithm The algorithm type
* @param value The digest value
*/
void setX509Digest(const XMLCh * algorithm, const XMLCh * value);
/**
* \brief Add a CRL.
*
* Append an X509CRL element to the list of CRLs
* stored at the end of this KeyInfo element.
*
* @param crl A pointer to the base64 encoded CRL,
* exactly as it will appear in the XML structure.
*/
void setX509CRL(const XMLCh * crl);
/**
* \brief Add a CRL.
*
* Append an X509CRL element to the list of CRLs
* stored at the end of this KeyInfo element.
*
* @param crl A pointer to the base64 encoded CRL,
* exactly as it will appear in the XML structure.
*/
void appendX509CRL(const XMLCh * crl);
/**
* \brief Set the SKI element
*
* The SKI node provides a reference to the Subject Key Identifier of
* a certificate.
*
* This function takes a base64 encoded ski and sets it into the
* appropriate node
*
* @param ski The base64 plain (non-DER) encoded SKI value
*/
void setX509SKI(const XMLCh * ski);
/**
* \brief set the retrieval URI
*
* Generally to be used by internal library processes only.
* This sets the retrieval URI - but does _not_ manipulate the DOM
* in any way.
*
* @param uri The URI string to use
*/
void setRawRetrievalURI(const XMLCh * uri);
/**
* \brief Add a certificate.
*
* Append an X509Certificate element to the list of certificates
* stored at the end of this KeyInfo element.
*
* @param base64Certificate A pointer to the base64 encoded certificate,
* exactly as it will appear in the XML structure.
*/
void appendX509Certificate(const XMLCh * base64Certificate);
//@}
private:
DSIGKeyInfoX509();
X509ListType m_X509List; // The X509 structures
X509CRLListType m_X509CRLList; // The X509CRL list
XMLCh * mp_X509IssuerName; // Parameters from KeyInfo (not cert)
const XMLCh * mp_X509SerialNumber;
XMLCh * mp_X509SubjectName;
const XMLCh * mp_X509SKI;
XMLCh * mp_rawRetrievalURI;
// Text nodes holding information
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509SubjectNameTextNode;
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509IssuerNameTextNode;
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509SerialNumberTextNode;
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509SKITextNode;
XERCES_CPP_NAMESPACE_QUALIFIER DOMNode * mp_X509DigestTextNode;
};
#endif /* #define DSIGKEYX509_INCLUDE */
|