67 #include <QtCore/qatomic.h> 68 #include <QtCore/qbytearray.h> 69 #include <QtCore/qiodevice.h> 70 #ifndef QT_NO_DEBUG_STREAM 71 #include <QtCore/qdebug.h> 128 void *phrase = (
void *)passPhrase.
constData();
164 return QByteArray(
"-----BEGIN PUBLIC KEY-----\n");
166 return QByteArray(
"-----BEGIN RSA PRIVATE KEY-----\n");
167 return QByteArray(
"-----BEGIN DSA PRIVATE KEY-----\n");
177 return QByteArray(
"-----END PUBLIC KEY-----\n");
179 return QByteArray(
"-----END RSA PRIVATE KEY-----\n");
180 return QByteArray(
"-----END DSA PRIVATE KEY-----\n");
195 const int lineWidth = 64;
196 const int newLines = pem.
size() / lineWidth;
197 const bool rem = pem.size() % lineWidth;
200 for (
int i = 0; i < newLines; ++i)
201 pem.insert((i + 1) * lineWidth + i,
'\n');
205 pem.prepend(pemHeader());
206 pem.append(pemFooter());
226 const int headerIndex = der.
indexOf(header);
227 const int footerIndex = der.
indexOf(footer);
228 if (headerIndex == -1 || footerIndex == -1)
231 der = der.
mid(headerIndex + header.
size(), footerIndex - (headerIndex + header.
size()));
462 #ifndef QT_NO_DEBUG_STREAM QByteArray pemFromDer(const QByteArray &der) const
Returns a DER key formatted as PEM.
The QDebug class provides an output stream for debugging information.
QSsl::KeyAlgorithm algorithm() const
Returns the key algorithm.
The QSslKey class provides an interface for private and public keys.
QExplicitlySharedDataPointer< QSslKeyPrivate > d
BIO_METHOD * q_BIO_s_mem()
#define QT_END_NAMESPACE
This macro expands to.
QByteArray toPem(const QByteArray &passPhrase=QByteArray()) const
Returns the key in PEM encoding.
char * data()
Returns a pointer to the data stored in the byte array.
Qt::HANDLE handle() const
Returns a pointer to the native key handle, if it is available; otherwise a null pointer is returned...
The QByteArray class provides an array of bytes.
int q_PEM_write_bio_RSAPrivateKey(BIO *a, RSA *b, const EVP_CIPHER *c, unsigned char *d, int e, pem_password_cb *f, void *g)
QByteArray toDer(const QByteArray &passPhrase=QByteArray()) const
Returns the key in DER encoding.
QSsl::KeyAlgorithm algorithm
DSA * q_PEM_read_bio_DSAPrivateKey(BIO *a, DSA **b, pem_password_cb *c, void *d)
int q_BN_num_bits(const BIGNUM *a)
static bool supportsSsl()
Returns true if this platform supports SSL; otherwise, returns false.
QSslKey()
Constructs a null key.
RSA * q_PEM_read_bio_RSA_PUBKEY(BIO *a, RSA **b, pem_password_cb *c, void *d)
#define QT_BEGIN_NAMESPACE
This macro expands to.
BIO * q_BIO_new(BIO_METHOD *a)
QByteArray derFromPem(const QByteArray &pem) const
Returns a PEM key formatted as DER.
void decodePem(const QByteArray &pem, const QByteArray &passPhrase, bool deepClear=true)
Allocates a new rsa or dsa struct and decodes pem into it according to the current algorithm and type...
QByteArray pemFooter() const
RSA * q_PEM_read_bio_RSAPrivateKey(BIO *a, RSA **b, pem_password_cb *c, void *d)
static const char * data(const QByteArray &arr)
int q_PEM_write_bio_DSA_PUBKEY(BIO *a, DSA *b)
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
int q_PEM_write_bio_RSA_PUBKEY(BIO *a, RSA *b)
const char * constData() const
Returns a pointer to the data stored in the byte array.
static QByteArray fromBase64(const QByteArray &base64)
Returns a decoded copy of the Base64 array base64.
void clear()
Clears the contents of this key, making it a null key.
EncodingFormat
Describes supported encoding formats for certificates and keys.
DSA * q_PEM_read_bio_DSA_PUBKEY(BIO *a, DSA **b, pem_password_cb *c, void *d)
void clear(bool deep=true)
QDebug operator<<(QDebug debug, const QSslKey &key)
BIO * q_BIO_new_mem_buf(void *a, int b)
QByteArray toBase64() const
Returns a copy of the byte array, encoded as Base64.
QByteArray readAll()
Reads all available data from the device, and returns it as a QByteArray.
int size() const
Returns the number of bytes in this byte array.
QByteArray pemHeader() const
~QSslKey()
Destroys the QSslKey object.
QSslKey & operator=(const QSslKey &other)
Copies the contents of other into this key, making the two keys identical.
bool isNull() const
Returns true if this is a null key; otherwise false.
KeyAlgorithm
Describes the different key algorithms supported by QSslKey.
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
KeyType
Describes the two types of keys QSslKey supports.
int q_PEM_write_bio_DSAPrivateKey(BIO *a, DSA *b, const EVP_CIPHER *c, unsigned char *d, int e, pem_password_cb *f, void *g)
const EVP_CIPHER * q_EVP_des_ede3_cbc()
int length() const
Returns the length of the key in bits, or -1 if the key is null.
The QIODevice class is the base interface class of all I/O devices in Qt.
#define q_BIO_get_mem_data(b, pp)
bool operator==(const QSslKey &key) const
Returns true if this key is equal to other; otherwise returns false.
QSsl::KeyType type() const
Returns the type of the key (i.e., PublicKey or PrivateKey).