QCA::KeyBundle

Search for usage in LXR

#include <QtCrypto>

Public Member Functions

 KeyBundle ()
 
 KeyBundle (const KeyBundle &from)
 
 KeyBundle (const QString &fileName, const SecureArray &passphrase=SecureArray())
 
CertificateChain certificateChain () const
 
bool isNull () const
 
QString name () const
 
KeyBundleoperator= (const KeyBundle &from)
 
PrivateKey privateKey () const
 
void setCertificateChainAndKey (const CertificateChain &c, const PrivateKey &key)
 
void setName (const QString &s)
 
QByteArray toArray (const SecureArray &passphrase, const QString &provider=QString()) const
 
bool toFile (const QString &fileName, const SecureArray &passphrase, const QString &provider=QString()) const
 

Static Public Member Functions

static KeyBundle fromArray (const QByteArray &a, const SecureArray &passphrase=SecureArray(), ConvertResult *result=nullptr, const QString &provider=QString())
 
static KeyBundle fromFile (const QString &fileName, const SecureArray &passphrase=SecureArray(), ConvertResult *result=nullptr, const QString &provider=QString())
 

Detailed Description

Certificate chain and private key pair.

KeyBundle is essentially a convience class that holds a certificate chain and an associated private key. This class has a number of methods that make it particularly suitable for accessing a PKCS12 (.p12) format file, however it can be used as just a container for a Certificate, its associated PrivateKey and optionally additional X.509 Certificate that form a chain.

For more information on PKCS12 "Personal Information Exchange Syntax Standard", see ftp://ftp.rsasecurity.com/pub/pkcs/pkcs-12/pkcs-12v1.pdf.

Definition at line 2175 of file qca_cert.h.

Constructor & Destructor Documentation

◆ KeyBundle() [1/3]

QCA::KeyBundle::KeyBundle ( )

Create an empty KeyBundle.

◆ KeyBundle() [2/3]

QCA::KeyBundle::KeyBundle ( const QString & fileName,
const SecureArray & passphrase = SecureArray() )
explicit

Create a KeyBundle from a PKCS12 (.p12) encoded file.

This constructor requires appropriate plugin (provider) support. You must check for the "pkcs12" feature before using this constructor.

Parameters
fileNamethe name of the file to read from
passphrasethe passphrase that is applicable to the file
See also
fromFile for a more flexible version of the same capability.
Note
This synchronous operation may require event handling, and so it must not be called from the same thread as an EventHandler.

◆ KeyBundle() [3/3]

QCA::KeyBundle::KeyBundle ( const KeyBundle & from)

Standard copy constructor.

Parameters
fromthe KeyBundle to use as source

Member Function Documentation

◆ certificateChain()

CertificateChain QCA::KeyBundle::certificateChain ( ) const

The public certificate part of this bundle.

See also
setCertificateChainAndKey

◆ fromArray()

static KeyBundle QCA::KeyBundle::fromArray ( const QByteArray & a,
const SecureArray & passphrase = SecureArray(),
ConvertResult * result = nullptr,
const QString & provider = QString() )
static

Import the key bundle from an array in PKCS12 format.

This method requires appropriate plugin (provider) support - you must check for the "pkcs12" feature, as shown below.

if( QCA::isSupported("pkcs12") )
{
// can use I/O
bundle = QCA::KeyBundle::fromArray( array, "pass phrase" );
}
else
{
// not possible to use I/O
}
static KeyBundle fromArray(const QByteArray &a, const SecureArray &passphrase=SecureArray(), ConvertResult *result=nullptr, const QString &provider=QString())
Import the key bundle from an array in PKCS12 format.
QCA_EXPORT bool isSupported(const char *features, const QString &provider=QString())
Test if a capability (algorithm) is available.
Parameters
athe array to import from
passphrasethe passphrase for the encoded bundle
resultpointer to the result of the import process
providerthe provider to use, if a specific provider is required
See also
QCA::KeyLoader for an asynchronous loader approach.
Note
This synchronous operation may require event handling, and so it must not be called from the same thread as an EventHandler.

◆ fromFile()

static KeyBundle QCA::KeyBundle::fromFile ( const QString & fileName,
const SecureArray & passphrase = SecureArray(),
ConvertResult * result = nullptr,
const QString & provider = QString() )
static

Import the key bundle from a file in PKCS12 (.p12) format.

This method requires appropriate plugin (provider) support - you must check for the "pkcs12" feature, as shown below.

if( QCA::isSupported("pkcs12") )
{
// can use I/O
bundle = QCA::KeyBundle::fromFile( filename, "pass phrase" );
}
else
{
// not possible to use I/O
}
static KeyBundle fromFile(const QString &fileName, const SecureArray &passphrase=SecureArray(), ConvertResult *result=nullptr, const QString &provider=QString())
Import the key bundle from a file in PKCS12 (.p12) format.
Parameters
fileNamethe name of the file to read from
passphrasethe passphrase for the encoded bundle
resultpointer to the result of the import process
providerthe provider to use, if a specific provider is required
See also
QCA::KeyLoader for an asynchronous loader approach.
Note
This synchronous operation may require event handling, and so it must not be called from the same thread as an EventHandler.

◆ isNull()

bool QCA::KeyBundle::isNull ( ) const

Test if this key is empty (null)

◆ name()

QString QCA::KeyBundle::name ( ) const

The name associated with this key.

This is also known as the "friendly name", and if present, is typically suitable to be displayed to the user.

See also
setName

◆ operator=()

KeyBundle & QCA::KeyBundle::operator= ( const KeyBundle & from)

Standard assignment operator.

Parameters
fromthe KeyBundle to use as source

◆ privateKey()

PrivateKey QCA::KeyBundle::privateKey ( ) const

The private key part of this bundle.

See also
setCertificateChainAndKey

◆ setCertificateChainAndKey()

void QCA::KeyBundle::setCertificateChainAndKey ( const CertificateChain & c,
const PrivateKey & key )

Set the public certificate and private key.

Parameters
cthe CertificateChain containing the public part of the Bundle
keythe private key part of the Bundle
See also
privateKey, certificateChain for getters

◆ setName()

void QCA::KeyBundle::setName ( const QString & s)

Specify the name of this bundle.

Parameters
sthe name to use

◆ toArray()

QByteArray QCA::KeyBundle::toArray ( const SecureArray & passphrase,
const QString & provider = QString() ) const

Export the key bundle to an array in PKCS12 format.

This method requires appropriate plugin (provider) support - you must check for the "pkcs12" feature, as shown below.

if( QCA::isSupported("pkcs12") )
{
// can use I/O
byteArray = bundle.toArray( "pass phrase" );
}
else
{
// not possible to use I/O
}
Parameters
passphrasethe passphrase to use to protect the bundle
providerthe provider to use, if a specific provider is required

◆ toFile()

bool QCA::KeyBundle::toFile ( const QString & fileName,
const SecureArray & passphrase,
const QString & provider = QString() ) const

Export the key bundle to a file in PKCS12 (.p12) format.

This method requires appropriate plugin (provider) support - you must check for the "pkcs12" feature, as shown below.

if( QCA::isSupported("pkcs12") )
{
// can use I/O
bool result = bundle.toFile( filename, "pass phrase" );
}
else
{
// not possible to use I/O
}
Parameters
fileNamethe name of the file to save to
passphrasethe passphrase to use to protect the bundle
providerthe provider to use, if a specific provider is required

The documentation for this class was generated from the following file:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 11:53:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.