mirror of
https://github.com/QuasarApp/qca.git
synced 2025-04-26 11:34:32 +00:00
QSecureArray/QBigInteger -> QCA::SecureArray/QCA::BigInteger
svn path=/trunk/kdesupport/qca/; revision=653598
This commit is contained in:
parent
74409900f8
commit
924d5a685f
@ -19,8 +19,8 @@
|
||||
\section features Features
|
||||
|
||||
This library provides an easy API for the following features:
|
||||
- Secure byte arrays (QSecureArray)
|
||||
- Arbitrary precision integers (QBigInteger)
|
||||
- Secure byte arrays (QCA::SecureArray)
|
||||
- Arbitrary precision integers (QCA::BigInteger)
|
||||
- Random number generation (QCA::Random)
|
||||
- SSL/TLS (QCA::TLS)
|
||||
- X509 certificates (QCA::Certificate and QCA::CertificateCollection)
|
||||
|
@ -80,7 +80,7 @@ namespace QCA
|
||||
*
|
||||
* \sa randomArray
|
||||
*/
|
||||
QSecureArray nextBytes(int size);
|
||||
SecureArray nextBytes(int size);
|
||||
|
||||
/**
|
||||
* Provide a random character (byte)
|
||||
@ -111,12 +111,12 @@ namespace QCA
|
||||
*
|
||||
* \code
|
||||
* // build a 30 byte secure array.
|
||||
* QSecureArray arry = QCA::Random::randomArray(30);
|
||||
* SecureArray arry = QCA::Random::randomArray(30);
|
||||
* \endcode
|
||||
*
|
||||
* \param size the number of bytes to provide
|
||||
*/
|
||||
static QSecureArray randomArray(int size);
|
||||
static SecureArray randomArray(int size);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -200,7 +200,7 @@ namespace QCA
|
||||
*
|
||||
* \param a the byte array to add to the hash
|
||||
*/
|
||||
virtual void update(const QSecureArray &a);
|
||||
virtual void update(const SecureArray &a);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
@ -214,7 +214,7 @@ namespace QCA
|
||||
*
|
||||
* This method is provided to assist with code that
|
||||
* already exists, and is being ported to %QCA. You are
|
||||
* better off passing a QSecureArray (as shown above)
|
||||
* better off passing a SecureArray (as shown above)
|
||||
* if you are writing new code.
|
||||
*
|
||||
* \param data pointer to a char array
|
||||
@ -261,19 +261,19 @@ namespace QCA
|
||||
* reuse the Hash object, you should call clear() and
|
||||
* start to update() again.
|
||||
*/
|
||||
virtual QSecureArray final();
|
||||
virtual SecureArray final();
|
||||
|
||||
/**
|
||||
* %Hash a byte array, returning it as another
|
||||
* byte array.
|
||||
*
|
||||
* This is a convenience method that returns the
|
||||
* hash of a QSecureArray.
|
||||
* hash of a SecureArray.
|
||||
*
|
||||
* \code
|
||||
* QSecureArray sampleArray(3);
|
||||
* SecureArray sampleArray(3);
|
||||
* sampleArray.fill('a');
|
||||
* QSecureArray outputArray = QCA::Hash("md2")::hash(sampleArray);
|
||||
* SecureArray outputArray = QCA::Hash("md2")::hash(sampleArray);
|
||||
* \endcode
|
||||
*
|
||||
* \param array the QByteArray to hash
|
||||
@ -283,7 +283,7 @@ namespace QCA
|
||||
* consider creating an Hash object, and then calling
|
||||
* update() and final().
|
||||
*/
|
||||
QSecureArray hash(const QSecureArray &array);
|
||||
SecureArray hash(const SecureArray &array);
|
||||
|
||||
/**
|
||||
* %Hash a byte array, returning it as a printable
|
||||
@ -299,7 +299,7 @@ namespace QCA
|
||||
* object, call Hash::update() as required, then call
|
||||
* Hash::final(), before using the static arrayToHex() method.
|
||||
*/
|
||||
QString hashToString(const QSecureArray &array);
|
||||
QString hashToString(const SecureArray &array);
|
||||
};
|
||||
|
||||
/** \page hashing Hashing Algorithms
|
||||
@ -560,13 +560,13 @@ namespace QCA
|
||||
*
|
||||
* \param a the array of data to encrypt / decrypt
|
||||
*/
|
||||
virtual QSecureArray update(const QSecureArray &a);
|
||||
virtual SecureArray update(const SecureArray &a);
|
||||
|
||||
/**
|
||||
* complete the block of data, padding as required, and returning
|
||||
* the completed block
|
||||
*/
|
||||
virtual QSecureArray final();
|
||||
virtual SecureArray final();
|
||||
|
||||
/**
|
||||
|
||||
@ -683,7 +683,7 @@ namespace QCA
|
||||
*
|
||||
* \param array the message contents
|
||||
*/
|
||||
virtual void update(const QSecureArray &array);
|
||||
virtual void update(const SecureArray &array);
|
||||
|
||||
/**
|
||||
* Finalises input and returns the MAC result
|
||||
@ -696,7 +696,7 @@ namespace QCA
|
||||
* reuse the %MessageAuthenticationCode object, you
|
||||
* should call clear() and start to update() again.
|
||||
*/
|
||||
virtual QSecureArray final();
|
||||
virtual SecureArray final();
|
||||
|
||||
/**
|
||||
* Initialise the MAC algorithm.
|
||||
@ -751,7 +751,7 @@ namespace QCA
|
||||
*
|
||||
* \return the derived key
|
||||
*/
|
||||
SymmetricKey makeKey(const QSecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount);
|
||||
SymmetricKey makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount);
|
||||
|
||||
/**
|
||||
* Construct the name of the algorithm
|
||||
|
@ -386,7 +386,7 @@ namespace QCA
|
||||
/**
|
||||
The serial number for the certificate
|
||||
*/
|
||||
QBigInteger serialNumber() const; // create
|
||||
BigInteger serialNumber() const; // create
|
||||
|
||||
/**
|
||||
the first time the certificate will be valid
|
||||
@ -459,7 +459,7 @@ namespace QCA
|
||||
|
||||
\param i the serial number to use
|
||||
*/
|
||||
void setSerialNumber(const QBigInteger &i);
|
||||
void setSerialNumber(const BigInteger &i);
|
||||
|
||||
/**
|
||||
Set the validity period for the certificate
|
||||
@ -616,7 +616,7 @@ namespace QCA
|
||||
/**
|
||||
The serial number of the certificate
|
||||
*/
|
||||
QBigInteger serialNumber() const;
|
||||
BigInteger serialNumber() const;
|
||||
|
||||
/**
|
||||
The public key associated with the subject of the certificate
|
||||
@ -678,7 +678,7 @@ namespace QCA
|
||||
/**
|
||||
Export the Certificate into a DER format
|
||||
*/
|
||||
QSecureArray toDER() const;
|
||||
SecureArray toDER() const;
|
||||
|
||||
/**
|
||||
Export the Certificate into a PEM format
|
||||
@ -701,7 +701,7 @@ namespace QCA
|
||||
|
||||
\return the Certificate corresponding to the certificate in the provided array
|
||||
*/
|
||||
static Certificate fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
static Certificate fromDER(const SecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import the certificate from PEM format
|
||||
@ -992,7 +992,7 @@ namespace QCA
|
||||
|
||||
\note this only applies to PKCS#10 format certificate requests
|
||||
*/
|
||||
QSecureArray toDER() const;
|
||||
SecureArray toDER() const;
|
||||
|
||||
/**
|
||||
Export the Certificate Request into a PEM format
|
||||
@ -1021,7 +1021,7 @@ namespace QCA
|
||||
|
||||
\note this only applies to PKCS#10 format certificate requests
|
||||
*/
|
||||
static CertificateRequest fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
static CertificateRequest fromDER(const SecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import the certificate request from PEM format
|
||||
@ -1127,12 +1127,12 @@ namespace QCA
|
||||
\param time the time the Certificate was revoked (or will be revoked)
|
||||
\param r the reason that the certificate is being revoked
|
||||
*/
|
||||
CRLEntry(const QBigInteger serial, const QDateTime time, Reason r = Unspecified);
|
||||
CRLEntry(const BigInteger serial, const QDateTime time, Reason r = Unspecified);
|
||||
|
||||
/**
|
||||
The serial number of the certificate that is the subject of this CRL entry
|
||||
*/
|
||||
QBigInteger serialNumber() const;
|
||||
BigInteger serialNumber() const;
|
||||
|
||||
/**
|
||||
The time this CRL entry was created
|
||||
@ -1168,7 +1168,7 @@ namespace QCA
|
||||
bool operator==(const CRLEntry &a) const;
|
||||
|
||||
private:
|
||||
QBigInteger _serial;
|
||||
BigInteger _serial;
|
||||
QDateTime _time;
|
||||
Reason _reason;
|
||||
};
|
||||
@ -1261,7 +1261,7 @@ namespace QCA
|
||||
/**
|
||||
The signature on this CRL
|
||||
*/
|
||||
QSecureArray signature() const;
|
||||
SecureArray signature() const;
|
||||
|
||||
/**
|
||||
The signature algorithm used for the signature on this CRL
|
||||
@ -1285,7 +1285,7 @@ namespace QCA
|
||||
|
||||
\return an array containing the CRL in DER format
|
||||
*/
|
||||
QSecureArray toDER() const;
|
||||
SecureArray toDER() const;
|
||||
|
||||
/**
|
||||
Export the %Certificate Revocation List (CRL) in PEM format
|
||||
@ -1310,7 +1310,7 @@ namespace QCA
|
||||
|
||||
\return the CRL corresponding to the contents of the array
|
||||
*/
|
||||
static CRL fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
static CRL fromDER(const SecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import a PEM encoded %Certificate Revocation List (CRL)
|
||||
@ -1583,7 +1583,7 @@ namespace QCA
|
||||
\sa fromFile for a more flexible version of the
|
||||
same capability.
|
||||
*/
|
||||
KeyBundle(const QString &fileName, const QSecureArray &passphrase = QSecureArray());
|
||||
KeyBundle(const QString &fileName, const SecureArray &passphrase = SecureArray());
|
||||
|
||||
/**
|
||||
Standard copy constructor
|
||||
@ -1668,7 +1668,7 @@ namespace QCA
|
||||
\param passphrase the passphrase to use to protect the bundle
|
||||
\param provider the provider to use, if a specific provider is required
|
||||
*/
|
||||
QByteArray toArray(const QSecureArray &passphrase, const QString &provider = QString()) const;
|
||||
QByteArray toArray(const SecureArray &passphrase, const QString &provider = QString()) const;
|
||||
|
||||
/**
|
||||
Export the key bundle to a file in PKCS12 (.p12) format
|
||||
@ -1690,7 +1690,7 @@ namespace QCA
|
||||
\param passphrase the passphrase to use to protect the bundle
|
||||
\param provider the provider to use, if a specific provider is required
|
||||
*/
|
||||
bool toFile(const QString &fileName, const QSecureArray &passphrase, const QString &provider = QString()) const;
|
||||
bool toFile(const QString &fileName, const SecureArray &passphrase, const QString &provider = QString()) const;
|
||||
|
||||
/**
|
||||
Import the key bundle from an array in PKCS12 format
|
||||
@ -1713,7 +1713,7 @@ namespace QCA
|
||||
\param result pointer to the result of the import process
|
||||
\param provider the provider to use, if a specific provider is required
|
||||
*/
|
||||
static KeyBundle fromArray(const QByteArray &a, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
static KeyBundle fromArray(const QByteArray &a, const SecureArray &passphrase = SecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import the key bundle from a file in PKCS12 (.p12) format
|
||||
@ -1736,7 +1736,7 @@ namespace QCA
|
||||
\param result pointer to the result of the import process
|
||||
\param provider the provider to use, if a specific provider is required
|
||||
*/
|
||||
static KeyBundle fromFile(const QString &fileName, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
static KeyBundle fromFile(const QString &fileName, const SecureArray &passphrase = SecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
private:
|
||||
class Private;
|
||||
@ -1863,7 +1863,7 @@ namespace QCA
|
||||
\sa fromArray for a static import method.
|
||||
\sa toString for an "ascii armoured" export method.
|
||||
*/
|
||||
QSecureArray toArray() const;
|
||||
SecureArray toArray() const;
|
||||
|
||||
/**
|
||||
Export the key to a string
|
||||
@ -1890,7 +1890,7 @@ namespace QCA
|
||||
\param provider the provider to use, if a particular provider is required
|
||||
*/
|
||||
|
||||
static PGPKey fromArray(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
static PGPKey fromArray(const SecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import the key from a string
|
||||
@ -1921,7 +1921,7 @@ namespace QCA
|
||||
|
||||
void loadPrivateKeyFromPEMFile(const QString &fileName);
|
||||
void loadPrivateKeyFromPEM(const QString &s);
|
||||
void loadPrivateKeyFromDER(const QSecureArray &a);
|
||||
void loadPrivateKeyFromDER(const SecureArray &a);
|
||||
void loadKeyBundleFromFile(const QString &fileName);
|
||||
void loadKeyBundleFromArray(const QByteArray &a);
|
||||
|
||||
|
@ -475,10 +475,10 @@ namespace QCA
|
||||
* representation.
|
||||
*
|
||||
* This is a convenience function to convert an arbitrary
|
||||
* QSecureArray to a printable representation.
|
||||
* SecureArray to a printable representation.
|
||||
*
|
||||
* \code
|
||||
* QSecureArray test(10);
|
||||
* SecureArray test(10);
|
||||
* test.fill('a');
|
||||
* // 0x61 is 'a' in ASCII
|
||||
* if (QString("61616161616161616161") == QCA::arrayToHex(test) ) {
|
||||
@ -489,7 +489,7 @@ namespace QCA
|
||||
* \param array the array to be converted
|
||||
* \return a printable representation
|
||||
*/
|
||||
QCA_EXPORT QString arrayToHex(const QSecureArray &array);
|
||||
QCA_EXPORT QString arrayToHex(const SecureArray &array);
|
||||
|
||||
/**
|
||||
* Convert a QString containing a hexadecimal representation
|
||||
@ -809,12 +809,12 @@ namespace QCA
|
||||
\param a the byte array of data that is to
|
||||
be used to update the internal state.
|
||||
*/
|
||||
virtual void update(const QSecureArray &a) = 0;
|
||||
virtual void update(const SecureArray &a) = 0;
|
||||
|
||||
/**
|
||||
Complete the algorithm and return the internal state
|
||||
*/
|
||||
virtual QSecureArray final() = 0;
|
||||
virtual SecureArray final() = 0;
|
||||
|
||||
/**
|
||||
Perform an "all in one" update, returning
|
||||
@ -826,7 +826,7 @@ namespace QCA
|
||||
\note This will invalidate any previous
|
||||
computation using this object.
|
||||
*/
|
||||
QSecureArray process(const QSecureArray &a);
|
||||
SecureArray process(const SecureArray &a);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -861,13 +861,13 @@ namespace QCA
|
||||
|
||||
\param a the array containing data to process
|
||||
*/
|
||||
virtual QSecureArray update(const QSecureArray &a) = 0;
|
||||
virtual SecureArray update(const SecureArray &a) = 0;
|
||||
|
||||
/**
|
||||
Complete the algorithm, returning any
|
||||
additional results.
|
||||
*/
|
||||
virtual QSecureArray final() = 0;
|
||||
virtual SecureArray final() = 0;
|
||||
|
||||
/**
|
||||
Test if an update() or final() call succeeded.
|
||||
@ -886,7 +886,7 @@ namespace QCA
|
||||
\note This will invalidate any previous
|
||||
computation using this object.
|
||||
*/
|
||||
QSecureArray process(const QSecureArray &a);
|
||||
SecureArray process(const SecureArray &a);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -995,7 +995,7 @@ namespace QCA
|
||||
|
||||
Container for keys for symmetric encryption algorithms.
|
||||
*/
|
||||
class QCA_EXPORT SymmetricKey : public QSecureArray
|
||||
class QCA_EXPORT SymmetricKey : public SecureArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -1018,7 +1018,7 @@ namespace QCA
|
||||
*
|
||||
* \param a the byte array to copy
|
||||
*/
|
||||
SymmetricKey(const QSecureArray &a);
|
||||
SymmetricKey(const SecureArray &a);
|
||||
|
||||
/**
|
||||
* Construct a key from a provided byte array
|
||||
@ -1040,7 +1040,7 @@ namespace QCA
|
||||
|
||||
Container for initialisation vectors and nonces
|
||||
*/
|
||||
class QCA_EXPORT InitializationVector : public QSecureArray
|
||||
class QCA_EXPORT InitializationVector : public SecureArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
@ -1060,7 +1060,7 @@ namespace QCA
|
||||
|
||||
\param a the byte array to copy
|
||||
*/
|
||||
InitializationVector(const QSecureArray &a);
|
||||
InitializationVector(const SecureArray &a);
|
||||
|
||||
/**
|
||||
Construct an initialisation vector from a provided byte array
|
||||
@ -1283,7 +1283,7 @@ namespace QCA
|
||||
\note the id parameter is the same as that provided in the
|
||||
eventReady() signal.
|
||||
*/
|
||||
void submitPassword(int id, const QSecureArray &password);
|
||||
void submitPassword(int id, const SecureArray &password);
|
||||
|
||||
/**
|
||||
function to call to indicate that the token has been inserted
|
||||
@ -1386,7 +1386,7 @@ namespace QCA
|
||||
The password / passphrase / PIN provided by the user in response to
|
||||
the asker request. This may be empty.
|
||||
*/
|
||||
QSecureArray password() const;
|
||||
SecureArray password() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
@ -131,7 +131,7 @@ namespace QCA
|
||||
function of QCA and does not utilize a provider. SHA1, MD5, MD2,
|
||||
and RIPEMD160 are supported.
|
||||
*/
|
||||
QCA_EXPORT QSecureArray emsa3Encode(const QString &hashName, const QSecureArray &digest, int size = -1);
|
||||
QCA_EXPORT SecureArray emsa3Encode(const QString &hashName, const SecureArray &digest, int size = -1);
|
||||
|
||||
/**
|
||||
\class DLGroup qca_publickey.h QtCrypto
|
||||
@ -150,7 +150,7 @@ namespace QCA
|
||||
\param q
|
||||
\param g
|
||||
*/
|
||||
DLGroup(const QBigInteger &p, const QBigInteger &q, const QBigInteger &g);
|
||||
DLGroup(const BigInteger &p, const BigInteger &q, const BigInteger &g);
|
||||
|
||||
/**
|
||||
Construct a discrete logarithm group from raw parameters
|
||||
@ -158,7 +158,7 @@ namespace QCA
|
||||
\param p
|
||||
\param g
|
||||
*/
|
||||
DLGroup(const QBigInteger &p, const QBigInteger &g);
|
||||
DLGroup(const BigInteger &p, const BigInteger &g);
|
||||
|
||||
/**
|
||||
Standard copy constructor
|
||||
@ -189,17 +189,17 @@ namespace QCA
|
||||
/**
|
||||
Provide the p component of the group
|
||||
*/
|
||||
QBigInteger p() const;
|
||||
BigInteger p() const;
|
||||
|
||||
/**
|
||||
Provide the q component of the group
|
||||
*/
|
||||
QBigInteger q() const;
|
||||
BigInteger q() const;
|
||||
|
||||
/**
|
||||
Provide the g component of the group
|
||||
*/
|
||||
QBigInteger g() const;
|
||||
BigInteger g() const;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
@ -537,7 +537,7 @@ namespace QCA
|
||||
\param a the message to encrypt
|
||||
\param alg the algorithm to use
|
||||
*/
|
||||
QSecureArray encrypt(const QSecureArray &a, EncryptionAlgorithm alg);
|
||||
SecureArray encrypt(const SecureArray &a, EncryptionAlgorithm alg);
|
||||
|
||||
/**
|
||||
Initialise the signature verification process
|
||||
@ -552,7 +552,7 @@ namespace QCA
|
||||
|
||||
\param a the array containing the data that should be added to the signature
|
||||
*/
|
||||
void update(const QSecureArray &a);
|
||||
void update(const SecureArray &a);
|
||||
|
||||
/**
|
||||
Check the signature is valid for the message
|
||||
@ -575,7 +575,7 @@ namespace QCA
|
||||
|
||||
\return true if the signature is correct
|
||||
*/
|
||||
bool validSignature(const QSecureArray &sig);
|
||||
bool validSignature(const SecureArray &sig);
|
||||
|
||||
/**
|
||||
Single step message verification
|
||||
@ -590,13 +590,13 @@ namespace QCA
|
||||
|
||||
\return true if the signature is valid for the message
|
||||
*/
|
||||
bool verifyMessage(const QSecureArray &a, const QSecureArray &sig, SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
|
||||
bool verifyMessage(const SecureArray &a, const SecureArray &sig, SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
|
||||
|
||||
|
||||
/**
|
||||
Export the key in Distinguished Encoding Rules (DER) format
|
||||
*/
|
||||
QSecureArray toDER() const;
|
||||
SecureArray toDER() const;
|
||||
|
||||
/**
|
||||
Export the key in Privacy Enhanced Mail (PEM) format
|
||||
@ -637,7 +637,7 @@ namespace QCA
|
||||
\param result pointer to a variable, which returns whether the conversion succeeded (ConvertGood) or not
|
||||
\param provider the name of the provider to use for the import.
|
||||
*/
|
||||
static PublicKey fromDER(const QSecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
static PublicKey fromDER(const SecureArray &a, ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import a key in Privacy Enhanced Mail (PEM) format
|
||||
@ -720,7 +720,7 @@ namespace QCA
|
||||
|
||||
\sa fromPEMFile for an alternative method
|
||||
*/
|
||||
PrivateKey(const QString &fileName, const QSecureArray &passphrase = QSecureArray());
|
||||
PrivateKey(const QString &fileName, const SecureArray &passphrase = SecureArray());
|
||||
|
||||
/**
|
||||
Interpret / convert the key to an RSA key
|
||||
@ -759,7 +759,7 @@ namespace QCA
|
||||
\param out the plain text data
|
||||
\param alg the algorithm to use
|
||||
*/
|
||||
bool decrypt(const QSecureArray &in, QSecureArray *out, EncryptionAlgorithm alg);
|
||||
bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
|
||||
|
||||
/**
|
||||
Initialise the message signature process
|
||||
@ -774,12 +774,12 @@ namespace QCA
|
||||
|
||||
\param a the message to use to update the signature
|
||||
*/
|
||||
void update(const QSecureArray &a);
|
||||
void update(const SecureArray &a);
|
||||
|
||||
/**
|
||||
The resulting signature
|
||||
*/
|
||||
QSecureArray signature();
|
||||
SecureArray signature();
|
||||
|
||||
/**
|
||||
One step signature process
|
||||
@ -790,7 +790,7 @@ namespace QCA
|
||||
|
||||
\return the signature
|
||||
*/
|
||||
QSecureArray signMessage(const QSecureArray &a, SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
|
||||
SecureArray signMessage(const SecureArray &a, SignatureAlgorithm alg, SignatureFormat format = DefaultFormat);
|
||||
|
||||
/**
|
||||
Derive a shared secret key from a public key
|
||||
@ -816,7 +816,7 @@ namespace QCA
|
||||
|
||||
\sa fromDER provides an inverse of toDER, converting the DER encoded key back to a PrivateKey
|
||||
*/
|
||||
QSecureArray toDER(const QSecureArray &passphrase = QSecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
||||
SecureArray toDER(const SecureArray &passphrase = SecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
||||
|
||||
/**
|
||||
Export the key in Privacy Enhanced Mail (PEM) format
|
||||
@ -827,7 +827,7 @@ namespace QCA
|
||||
\sa toPEMFile provides a convenient way to save the PEM encoded key to a file
|
||||
\sa fromPEM provides an inverse of toPEM, converting the PEM encoded key back to a PrivateKey
|
||||
*/
|
||||
QString toPEM(const QSecureArray &passphrase = QSecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
||||
QString toPEM(const SecureArray &passphrase = SecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
||||
|
||||
/**
|
||||
Export the key in Privacy Enhanced Mail (PEM) format to a file
|
||||
@ -841,7 +841,7 @@ namespace QCA
|
||||
\sa toPEM provides a convenient way to save the PEM encoded key to a file
|
||||
\sa fromPEM provides an inverse of toPEM, converting the PEM encoded key back to a PrivateKey
|
||||
*/
|
||||
bool toPEMFile(const QString &fileName, const QSecureArray &passphrase = QSecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
||||
bool toPEMFile(const QString &fileName, const SecureArray &passphrase = SecureArray(), PBEAlgorithm pbe = PBEDefault) const;
|
||||
|
||||
/**
|
||||
Import the key from Distinguished Encoding Rules (DER) format
|
||||
@ -854,7 +854,7 @@ namespace QCA
|
||||
|
||||
\sa toDER provides an inverse of fromDER, exporting the key to an array
|
||||
*/
|
||||
static PrivateKey fromDER(const QSecureArray &a, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
static PrivateKey fromDER(const SecureArray &a, const SecureArray &passphrase = SecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import the key from Privacy Enhanced Mail (PEM) format
|
||||
@ -867,7 +867,7 @@ namespace QCA
|
||||
|
||||
\sa toPEM provides an inverse of fromPEM, exporting the key to a string in PEM encoding.
|
||||
*/
|
||||
static PrivateKey fromPEM(const QString &s, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
static PrivateKey fromPEM(const QString &s, const SecureArray &passphrase = SecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Import the key in Privacy Enhanced Mail (PEM) format from a file
|
||||
@ -883,7 +883,7 @@ namespace QCA
|
||||
|
||||
\note there is also a constructor form, that allows you to create the key directly
|
||||
*/
|
||||
static PrivateKey fromPEMFile(const QString &fileName, const QSecureArray &passphrase = QSecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
static PrivateKey fromPEMFile(const QString &fileName, const SecureArray &passphrase = SecureArray(), ConvertResult *result = 0, const QString &provider = QString());
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -1041,7 +1041,7 @@ namespace QCA
|
||||
\param e the public key exponent
|
||||
\param provider the provider to use, if a particular provider is required
|
||||
*/
|
||||
RSAPublicKey(const QBigInteger &n, const QBigInteger &e, const QString &provider = QString());
|
||||
RSAPublicKey(const BigInteger &n, const BigInteger &e, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Extract the public key components from an RSA private key
|
||||
@ -1056,14 +1056,14 @@ namespace QCA
|
||||
This value is the actual public key value (the product of p and q, the random prime numbers
|
||||
used to generate the RSA key), also known as the public modulus.
|
||||
*/
|
||||
QBigInteger n() const;
|
||||
BigInteger n() const;
|
||||
|
||||
/**
|
||||
The public key exponent
|
||||
|
||||
This value is the exponent chosen in the original key generator step
|
||||
*/
|
||||
QBigInteger e() const;
|
||||
BigInteger e() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1089,7 +1089,7 @@ namespace QCA
|
||||
\param d inverse of the exponent, modulo (p-1)(q-1)
|
||||
\param provider the provider to use, if a particular provider is required
|
||||
*/
|
||||
RSAPrivateKey(const QBigInteger &n, const QBigInteger &e, const QBigInteger &p, const QBigInteger &q, const QBigInteger &d, const QString &provider = QString());
|
||||
RSAPrivateKey(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
The public key value
|
||||
@ -1097,29 +1097,29 @@ namespace QCA
|
||||
This value is the actual public key value (the product of p and q, the random prime numbers
|
||||
used to generate the RSA key), also known as the public modulus.
|
||||
*/
|
||||
QBigInteger n() const;
|
||||
BigInteger n() const;
|
||||
|
||||
/**
|
||||
The public key exponent
|
||||
|
||||
This value is the exponent chosen in the original key generator step
|
||||
*/
|
||||
QBigInteger e() const;
|
||||
BigInteger e() const;
|
||||
|
||||
/**
|
||||
One of the two random primes used to generate the private key
|
||||
*/
|
||||
QBigInteger p() const;
|
||||
BigInteger p() const;
|
||||
|
||||
/**
|
||||
The second of the two random primes used to generate the private key
|
||||
*/
|
||||
QBigInteger q() const;
|
||||
BigInteger q() const;
|
||||
|
||||
/**
|
||||
The inverse of the exponent, module (p-1)(q-1)
|
||||
*/
|
||||
QBigInteger d() const;
|
||||
BigInteger d() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1142,7 +1142,7 @@ namespace QCA
|
||||
\param y the public random value
|
||||
\param provider the provider to use, if a specific provider is required
|
||||
*/
|
||||
DSAPublicKey(const DLGroup &domain, const QBigInteger &y, const QString &provider = QString());
|
||||
DSAPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Create a DSA public key from a specified private key
|
||||
@ -1159,7 +1159,7 @@ namespace QCA
|
||||
/**
|
||||
The public random value associated with this key
|
||||
*/
|
||||
QBigInteger y() const;
|
||||
BigInteger y() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1183,7 +1183,7 @@ namespace QCA
|
||||
\param x the private random value
|
||||
\param provider the provider to use, if a specific provider is required
|
||||
*/
|
||||
DSAPrivateKey(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x, const QString &provider = QString());
|
||||
DSAPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
The discrete logarithm group that is being used
|
||||
@ -1193,12 +1193,12 @@ namespace QCA
|
||||
/**
|
||||
the public random value
|
||||
*/
|
||||
QBigInteger y() const;
|
||||
BigInteger y() const;
|
||||
|
||||
/**
|
||||
the private random value
|
||||
*/
|
||||
QBigInteger x() const;
|
||||
BigInteger x() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1221,7 +1221,7 @@ namespace QCA
|
||||
\param y the public random value
|
||||
\param provider the provider to use, if a specific provider is required
|
||||
*/
|
||||
DHPublicKey(const DLGroup &domain, const QBigInteger &y, const QString &provider = QString());
|
||||
DHPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
Create a Diffie-Hellman public key from a specified private key
|
||||
@ -1238,7 +1238,7 @@ namespace QCA
|
||||
/**
|
||||
The public random value associated with this key
|
||||
*/
|
||||
QBigInteger y() const;
|
||||
BigInteger y() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1262,7 +1262,7 @@ namespace QCA
|
||||
\param x the private random value
|
||||
\param provider the provider to use, if a particular provider is required
|
||||
*/
|
||||
DHPrivateKey(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x, const QString &provider = QString());
|
||||
DHPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider = QString());
|
||||
|
||||
/**
|
||||
The discrete logarithm group that is being used
|
||||
@ -1272,12 +1272,12 @@ namespace QCA
|
||||
/**
|
||||
The public random value associated with this key
|
||||
*/
|
||||
QBigInteger y() const;
|
||||
BigInteger y() const;
|
||||
|
||||
/**
|
||||
The private random value associated with this key
|
||||
*/
|
||||
QBigInteger x() const;
|
||||
BigInteger x() const;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -914,7 +914,7 @@ namespace QCA
|
||||
|
||||
\param pass the password to use
|
||||
*/
|
||||
void setPassword(const QSecureArray &pass);
|
||||
void setPassword(const SecureArray &pass);
|
||||
|
||||
/**
|
||||
Specify the realm to use in authentication
|
||||
|
@ -271,8 +271,8 @@ namespace QCA
|
||||
void write(const QByteArray &a);
|
||||
|
||||
// secure i/o
|
||||
QSecureArray readSecure(int bytes = -1);
|
||||
void writeSecure(const QSecureArray &a);
|
||||
SecureArray readSecure(int bytes = -1);
|
||||
void writeSecure(const SecureArray &a);
|
||||
|
||||
// close write channel (only if writing enabled)
|
||||
void closeOutput();
|
||||
@ -297,7 +297,7 @@ namespace QCA
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
static QSecureArray getHidden(const QString &promptStr);
|
||||
static SecureArray getHidden(const QString &promptStr);
|
||||
static void waitForEnter();
|
||||
|
||||
private:
|
||||
|
@ -75,7 +75,7 @@ namespace QCA
|
||||
|
||||
\param a the array to encode
|
||||
*/
|
||||
QSecureArray encode(const QSecureArray &a);
|
||||
SecureArray encode(const SecureArray &a);
|
||||
|
||||
/**
|
||||
Process an array in the "reverse" direction,
|
||||
@ -88,7 +88,7 @@ namespace QCA
|
||||
|
||||
\param a the array to decode
|
||||
*/
|
||||
QSecureArray decode(const QSecureArray &a);
|
||||
SecureArray decode(const SecureArray &a);
|
||||
|
||||
/**
|
||||
Process an array in the "forward" direction,
|
||||
@ -100,7 +100,7 @@ namespace QCA
|
||||
|
||||
\param a the array to encode
|
||||
*/
|
||||
QString arrayToString(const QSecureArray &a);
|
||||
QString arrayToString(const SecureArray &a);
|
||||
|
||||
/**
|
||||
Process an string in the "reverse" direction,
|
||||
@ -112,7 +112,7 @@ namespace QCA
|
||||
|
||||
\param s the array to decode
|
||||
*/
|
||||
QSecureArray stringToArray(const QString &s);
|
||||
SecureArray stringToArray(const QString &s);
|
||||
|
||||
/**
|
||||
Process a string in the "forward" direction,
|
||||
@ -185,7 +185,7 @@ namespace QCA
|
||||
|
||||
\param a the array containing data to process
|
||||
*/
|
||||
virtual QSecureArray update(const QSecureArray &a);
|
||||
virtual SecureArray update(const SecureArray &a);
|
||||
|
||||
/**
|
||||
Complete the algorithm
|
||||
@ -195,7 +195,7 @@ namespace QCA
|
||||
zero length array - any output will have been returned
|
||||
from the update() call.
|
||||
*/
|
||||
virtual QSecureArray final();
|
||||
virtual SecureArray final();
|
||||
|
||||
/**
|
||||
Test if an update() or final() call succeeded.
|
||||
@ -262,7 +262,7 @@ namespace QCA
|
||||
|
||||
\param a the array containing data to process
|
||||
*/
|
||||
virtual QSecureArray update(const QSecureArray &a);
|
||||
virtual SecureArray update(const SecureArray &a);
|
||||
|
||||
/**
|
||||
Complete the algorithm
|
||||
@ -272,7 +272,7 @@ namespace QCA
|
||||
empty array, or an array containing one or two
|
||||
"=" (equals, 0x3D) characters.
|
||||
*/
|
||||
virtual QSecureArray final();
|
||||
virtual SecureArray final();
|
||||
|
||||
/**
|
||||
Test if an update() or final() call succeeded.
|
||||
@ -282,7 +282,7 @@ namespace QCA
|
||||
virtual bool ok() const;
|
||||
|
||||
private:
|
||||
QSecureArray partial;
|
||||
SecureArray partial;
|
||||
bool _ok;
|
||||
int col;
|
||||
bool _lb_enabled;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* qca_tools.h - Qt Cryptographic Architecture
|
||||
* Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com>
|
||||
* Copyright (C) 2003-2007 Justin Karneges <justin@affinix.com>
|
||||
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -72,12 +72,14 @@ QCA_EXPORT void qca_secure_free(void *p);
|
||||
*/
|
||||
QCA_EXPORT void *qca_secure_realloc(void *p, int bytes);
|
||||
|
||||
namespace QCA {
|
||||
|
||||
/**
|
||||
\class QSecureArray qca_tools.h QtCrypto
|
||||
\class SecureArray qca_tools.h QtCrypto
|
||||
|
||||
Secure array of bytes
|
||||
|
||||
The %QSecureArray provides an array of memory from a pool that is,
|
||||
The %SecureArray provides an array of memory from a pool that is,
|
||||
at least partly, secure. In this sense, secure means that the contents
|
||||
of the memory should not be made available to other applications. By
|
||||
comparison, a QMemArray (or subclass such as QCString or QByteArray) may
|
||||
@ -86,13 +88,13 @@ QCA_EXPORT void *qca_secure_realloc(void *p, int bytes);
|
||||
|
||||
Note that this class is implicitly shared (that is, copy on write).
|
||||
**/
|
||||
class QCA_EXPORT QSecureArray
|
||||
class QCA_EXPORT SecureArray
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Construct a secure byte array, zero length
|
||||
*/
|
||||
QSecureArray();
|
||||
SecureArray();
|
||||
|
||||
/**
|
||||
* Construct a secure byte array of the specified length
|
||||
@ -100,14 +102,14 @@ public:
|
||||
* \param size the number of bytes in the array
|
||||
* \param ch the value every byte should be set to
|
||||
*/
|
||||
QSecureArray(int size, char ch = 0);
|
||||
SecureArray(int size, char ch = 0);
|
||||
|
||||
/**
|
||||
* Construct a secure byte array from a string
|
||||
*
|
||||
* Note that this copies, rather than references the source array
|
||||
*/
|
||||
QSecureArray(const char *str);
|
||||
SecureArray(const char *str);
|
||||
|
||||
/**
|
||||
* Construct a secure byte array from a QByteArray
|
||||
@ -116,30 +118,30 @@ public:
|
||||
*
|
||||
* \sa operator=()
|
||||
*/
|
||||
QSecureArray(const QByteArray &a);
|
||||
SecureArray(const QByteArray &a);
|
||||
|
||||
/**
|
||||
* Construct a (shallow) copy of another secure byte array
|
||||
*
|
||||
* \param from the source of the data and length.
|
||||
*/
|
||||
QSecureArray(const QSecureArray &from);
|
||||
SecureArray(const SecureArray &from);
|
||||
|
||||
~QSecureArray();
|
||||
~SecureArray();
|
||||
|
||||
/**
|
||||
* Creates a reference, rather than a deep copy.
|
||||
* if you want a deep copy then you should use copy()
|
||||
* instead, or use operator=(), then call detach() when required.
|
||||
*/
|
||||
QSecureArray & operator=(const QSecureArray &from);
|
||||
SecureArray & operator=(const SecureArray &from);
|
||||
|
||||
/**
|
||||
* Creates a copy, rather than references
|
||||
*
|
||||
* \param a the array to copy from
|
||||
*/
|
||||
QSecureArray & operator=(const QByteArray &a);
|
||||
SecureArray & operator=(const QByteArray &a);
|
||||
|
||||
/**
|
||||
* Clears the contents of the array and makes it empty
|
||||
@ -257,12 +259,12 @@ public:
|
||||
/**
|
||||
* Append a secure byte array to the end of this array
|
||||
*/
|
||||
QSecureArray & append(const QSecureArray &a);
|
||||
SecureArray & append(const SecureArray &a);
|
||||
|
||||
/**
|
||||
* Append a secure byte array to the end of this array
|
||||
*/
|
||||
QSecureArray & operator+=(const QSecureArray &a);
|
||||
SecureArray & operator+=(const SecureArray &a);
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -271,7 +273,7 @@ protected:
|
||||
*
|
||||
* \param from the byte array to copy
|
||||
*/
|
||||
void set(const QSecureArray &from);
|
||||
void set(const SecureArray &from);
|
||||
|
||||
/**
|
||||
* Assign the contents of a provided byte array to this
|
||||
@ -286,60 +288,58 @@ private:
|
||||
QSharedDataPointer<Private> d;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QSecureArray)
|
||||
|
||||
/**
|
||||
* Equality operator. Returns true if the two QSecureArray
|
||||
* Equality operator. Returns true if the two SecureArray
|
||||
* arguments have the same data (and the same length, of course).
|
||||
*
|
||||
* \relates QSecureArray
|
||||
* \relates SecureArray
|
||||
**/
|
||||
QCA_EXPORT bool operator==(const QSecureArray &a, const QSecureArray &b);
|
||||
QCA_EXPORT bool operator==(const SecureArray &a, const SecureArray &b);
|
||||
|
||||
/**
|
||||
* Inequality operator. Returns true if the two QSecureArray
|
||||
* Inequality operator. Returns true if the two SecureArray
|
||||
* arguments have different length, or the same length but
|
||||
* different data
|
||||
*
|
||||
* \relates QSecureArray
|
||||
* \relates SecureArray
|
||||
**/
|
||||
QCA_EXPORT bool operator!=(const QSecureArray &a, const QSecureArray &b);
|
||||
QCA_EXPORT bool operator!=(const SecureArray &a, const SecureArray &b);
|
||||
|
||||
/**
|
||||
* Returns an array that is the result of concatenating a and b
|
||||
*
|
||||
* \relates QSecureArray
|
||||
* \relates SecureArray
|
||||
**/
|
||||
QCA_EXPORT const QSecureArray operator+(const QSecureArray &a, const QSecureArray &b);
|
||||
QCA_EXPORT const SecureArray operator+(const SecureArray &a, const SecureArray &b);
|
||||
|
||||
/**
|
||||
\class QBigInteger qca_tools.h QtCrypto
|
||||
\class BigInteger qca_tools.h QtCrypto
|
||||
|
||||
Arbitrary precision integer
|
||||
|
||||
QBigInteger provides arbitrary precision integers.
|
||||
BigInteger provides arbitrary precision integers.
|
||||
\code
|
||||
if ( QBigInteger("3499543804349") ==
|
||||
QBigInteger("38493290803248") + QBigInteger( 343 ) )
|
||||
if ( BigInteger("3499543804349") ==
|
||||
BigInteger("38493290803248") + BigInteger( 343 ) )
|
||||
{
|
||||
// do something
|
||||
}
|
||||
\endcode
|
||||
**/
|
||||
class QCA_EXPORT QBigInteger
|
||||
class QCA_EXPORT BigInteger
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor. Creates a new QBigInteger, initialised to zero.
|
||||
* Constructor. Creates a new BigInteger, initialised to zero.
|
||||
*/
|
||||
QBigInteger();
|
||||
BigInteger();
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param n an alternative integer initialisation value.
|
||||
*/
|
||||
QBigInteger(int n);
|
||||
BigInteger(int n);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
@ -347,46 +347,46 @@ public:
|
||||
* \param c an alternative initialisation value, encoded as a character array
|
||||
*
|
||||
* \code
|
||||
* QBigInteger b ( "9890343" );
|
||||
* BigInteger b ( "9890343" );
|
||||
* \endcode
|
||||
*/
|
||||
QBigInteger(const char *c);
|
||||
BigInteger(const char *c);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param s an alternative initialisation value, encoded as a string
|
||||
*/
|
||||
QBigInteger(const QString &s);
|
||||
BigInteger(const QString &s);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param a an alternative initialisation value, encoded as QSecureArray
|
||||
* \param a an alternative initialisation value, encoded as SecureArray
|
||||
*/
|
||||
QBigInteger(const QSecureArray &a);
|
||||
BigInteger(const QCA::SecureArray &a);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
*
|
||||
* \param from an alternative initialisation value, encoded as a %QBigInteger
|
||||
* \param from an alternative initialisation value, encoded as a %BigInteger
|
||||
*/
|
||||
QBigInteger(const QBigInteger &from);
|
||||
BigInteger(const BigInteger &from);
|
||||
|
||||
~QBigInteger();
|
||||
~BigInteger();
|
||||
|
||||
/**
|
||||
* Assignment operator
|
||||
*
|
||||
* \param from the QBigInteger to copy from
|
||||
* \param from the BigInteger to copy from
|
||||
*
|
||||
* \code
|
||||
* QBigInteger a; // a is zero
|
||||
* QBigInteger b( 500 );
|
||||
* BigInteger a; // a is zero
|
||||
* BigInteger b( 500 );
|
||||
* a = b; // a is now 500
|
||||
* \endcode
|
||||
*/
|
||||
QBigInteger & operator=(const QBigInteger &from);
|
||||
BigInteger & operator=(const BigInteger &from);
|
||||
|
||||
/**
|
||||
* \overload
|
||||
@ -400,7 +400,7 @@ public:
|
||||
* contains numbers and an optional minus sign at the start)
|
||||
*
|
||||
**/
|
||||
QBigInteger & operator=(const QString &s);
|
||||
BigInteger & operator=(const QString &s);
|
||||
|
||||
/**
|
||||
* Increment in place operator
|
||||
@ -408,13 +408,13 @@ public:
|
||||
* \param b the amount to increment by
|
||||
*
|
||||
* \code
|
||||
* QBigInteger a; // a is zero
|
||||
* QBigInteger b( 500 );
|
||||
* BigInteger a; // a is zero
|
||||
* BigInteger b( 500 );
|
||||
* a += b; // a is now 500
|
||||
* a += b; // a is now 1000
|
||||
* \endcode
|
||||
**/
|
||||
QBigInteger & operator+=(const QBigInteger &b);
|
||||
BigInteger & operator+=(const BigInteger &b);
|
||||
|
||||
/**
|
||||
* Decrement in place operator
|
||||
@ -422,40 +422,40 @@ public:
|
||||
* \param b the amount to decrement by
|
||||
*
|
||||
* \code
|
||||
* QBigInteger a; // a is zero
|
||||
* QBigInteger b( 500 );
|
||||
* BigInteger a; // a is zero
|
||||
* BigInteger b( 500 );
|
||||
* a -= b; // a is now -500
|
||||
* a -= b; // a is now -1000
|
||||
* \endcode
|
||||
**/
|
||||
QBigInteger & operator-=(const QBigInteger &b);
|
||||
BigInteger & operator-=(const BigInteger &b);
|
||||
|
||||
/**
|
||||
* Output %QBigInteger as a byte array, useful for storage or
|
||||
* Output %BigInteger as a byte array, useful for storage or
|
||||
* transmission. The format is a binary integer in sign-extended
|
||||
* network-byte-order.
|
||||
*
|
||||
* \sa void fromArray(const QSecureArray &a);
|
||||
* \sa void fromArray(const SecureArray &a);
|
||||
*/
|
||||
QSecureArray toArray() const;
|
||||
QCA::SecureArray toArray() const;
|
||||
|
||||
/**
|
||||
* Assign from an array. The input is expected to be a binary integer
|
||||
* in sign-extended network-byte-order.
|
||||
*
|
||||
* \param a a QSecureArray that represents an integer
|
||||
* \param a a SecureArray that represents an integer
|
||||
*
|
||||
* \sa QBigInteger(const QSecureArray &a);
|
||||
* \sa QSecureArray toArray() const;
|
||||
* \sa BigInteger(const SecureArray &a);
|
||||
* \sa SecureArray toArray() const;
|
||||
*/
|
||||
void fromArray(const QSecureArray &a);
|
||||
void fromArray(const QCA::SecureArray &a);
|
||||
|
||||
/**
|
||||
* Convert %QBigInteger to a QString
|
||||
* Convert %BigInteger to a QString
|
||||
*
|
||||
* \code
|
||||
* QString aString;
|
||||
* QBigInteger aBiggishInteger( 5878990 );
|
||||
* BigInteger aBiggishInteger( 5878990 );
|
||||
* aString = aBiggishInteger.toString(); // aString is now "5878990"
|
||||
* \endcode
|
||||
*/
|
||||
@ -470,108 +470,106 @@ public:
|
||||
* that the QString represents a valid integer (ie it only
|
||||
* contains numbers and an optional minus sign at the start)
|
||||
*
|
||||
* \sa QBigInteger(const QString &s)
|
||||
* \sa QBigInteger & operator=(const QString &s)
|
||||
* \sa BigInteger(const QString &s)
|
||||
* \sa BigInteger & operator=(const QString &s)
|
||||
*/
|
||||
bool fromString(const QString &s);
|
||||
|
||||
/**
|
||||
* Compare this value with another %QBigInteger
|
||||
* Compare this value with another %BigInteger
|
||||
*
|
||||
* Normally it is more readable to use one of the operator overloads,
|
||||
* so you don't need to use this method directly.
|
||||
*
|
||||
* \param n the QBigInteger to compare with
|
||||
* \param n the BigInteger to compare with
|
||||
*
|
||||
* \return zero if the values are the same, negative if the argument
|
||||
* is less than the value of this QBigInteger, and positive if the argument
|
||||
* value is greater than this QBigInteger
|
||||
* is less than the value of this BigInteger, and positive if the argument
|
||||
* value is greater than this BigInteger
|
||||
*
|
||||
* \code
|
||||
* QBigInteger a( "400" );
|
||||
* QBigInteger b( "-400" );
|
||||
* QBigInteger c( " 200 " );
|
||||
* BigInteger a( "400" );
|
||||
* BigInteger b( "-400" );
|
||||
* BigInteger c( " 200 " );
|
||||
* int result;
|
||||
* result = a.compare( b ); // return positive 400 > -400
|
||||
* result = a.compare( c ); // return positive, 400 > 200
|
||||
* result = b.compare( c ); // return negative, -400 < 200
|
||||
* \endcode
|
||||
**/
|
||||
int compare(const QBigInteger &n) const;
|
||||
int compare(const BigInteger &n) const;
|
||||
|
||||
private:
|
||||
class Private;
|
||||
QSharedDataPointer<Private> d;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QBigInteger)
|
||||
|
||||
/**
|
||||
* Equality operator. Returns true if the two QBigInteger values
|
||||
* Equality operator. Returns true if the two BigInteger values
|
||||
* are the same, including having the same sign.
|
||||
*
|
||||
* \relates QBigInteger
|
||||
* \relates BigInteger
|
||||
**/
|
||||
inline bool operator==(const QBigInteger &a, const QBigInteger &b)
|
||||
inline bool operator==(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (0 == a.compare( b ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Inequality operator. Returns true if the two QBigInteger values
|
||||
* Inequality operator. Returns true if the two BigInteger values
|
||||
* are different in magnitude, sign or both
|
||||
*
|
||||
* \relates QBigInteger
|
||||
* \relates BigInteger
|
||||
**/
|
||||
inline bool operator!=(const QBigInteger &a, const QBigInteger &b)
|
||||
inline bool operator!=(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (0 != a.compare( b ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Less than or equal operator. Returns true if the QBigInteger value
|
||||
* on the left hand side is equal to or less than the QBigInteger value
|
||||
* Less than or equal operator. Returns true if the BigInteger value
|
||||
* on the left hand side is equal to or less than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates QBigInteger
|
||||
* \relates BigInteger
|
||||
**/
|
||||
inline bool operator<=(const QBigInteger &a, const QBigInteger &b)
|
||||
inline bool operator<=(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) <= 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater than or equal operator. Returns true if the QBigInteger value
|
||||
* on the left hand side is equal to or greater than the QBigInteger value
|
||||
* Greater than or equal operator. Returns true if the BigInteger value
|
||||
* on the left hand side is equal to or greater than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates QBigInteger
|
||||
* \relates BigInteger
|
||||
**/
|
||||
inline bool operator>=(const QBigInteger &a, const QBigInteger &b)
|
||||
inline bool operator>=(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) >= 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Less than operator. Returns true if the QBigInteger value
|
||||
* on the left hand side is less than the QBigInteger value
|
||||
* Less than operator. Returns true if the BigInteger value
|
||||
* on the left hand side is less than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates QBigInteger
|
||||
* \relates BigInteger
|
||||
**/
|
||||
inline bool operator<(const QBigInteger &a, const QBigInteger &b)
|
||||
inline bool operator<(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) < 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater than operator. Returns true if the QBigInteger value
|
||||
* on the left hand side is greater than the QBigInteger value
|
||||
* Greater than operator. Returns true if the BigInteger value
|
||||
* on the left hand side is greater than the BigInteger value
|
||||
* on the right hand side.
|
||||
*
|
||||
* \relates QBigInteger
|
||||
* \relates BigInteger
|
||||
**/
|
||||
inline bool operator>(const QBigInteger &a, const QBigInteger &b)
|
||||
inline bool operator>(const BigInteger &a, const BigInteger &b)
|
||||
{
|
||||
return (a.compare( b ) > 0 );
|
||||
}
|
||||
@ -579,8 +577,13 @@ inline bool operator>(const QBigInteger &a, const QBigInteger &b)
|
||||
/**
|
||||
* Stream operator.
|
||||
*
|
||||
* \relates QBigInteger
|
||||
* \relates BigInteger
|
||||
**/
|
||||
QCA_EXPORT QTextStream &operator<<(QTextStream &stream, const QBigInteger &b);
|
||||
QCA_EXPORT QTextStream &operator<<(QTextStream &stream, const BigInteger &b);
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(QCA::SecureArray)
|
||||
Q_DECLARE_METATYPE(QCA::BigInteger)
|
||||
|
||||
#endif
|
||||
|
@ -49,7 +49,7 @@ class QCA_EXPORT RandomContext : public BasicContext
|
||||
Q_OBJECT
|
||||
public:
|
||||
RandomContext(Provider *p) : BasicContext(p, "random") {}
|
||||
virtual QSecureArray nextBytes(int size) = 0;
|
||||
virtual SecureArray nextBytes(int size) = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT HashContext : public BasicContext
|
||||
@ -58,8 +58,8 @@ class QCA_EXPORT HashContext : public BasicContext
|
||||
public:
|
||||
HashContext(Provider *p, const QString &type) : BasicContext(p, type) {}
|
||||
virtual void clear() = 0;
|
||||
virtual void update(const QSecureArray &a) = 0;
|
||||
virtual QSecureArray final() = 0;
|
||||
virtual void update(const SecureArray &a) = 0;
|
||||
virtual SecureArray final() = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT CipherContext : public BasicContext
|
||||
@ -71,8 +71,8 @@ public:
|
||||
virtual KeyLength keyLength() const = 0;
|
||||
virtual unsigned int blockSize() const = 0;
|
||||
|
||||
virtual bool update(const QSecureArray &in, QSecureArray *out) = 0;
|
||||
virtual bool final(QSecureArray *out) = 0;
|
||||
virtual bool update(const SecureArray &in, SecureArray *out) = 0;
|
||||
virtual bool final(SecureArray *out) = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT MACContext : public BasicContext
|
||||
@ -83,8 +83,8 @@ public:
|
||||
virtual void setup(const SymmetricKey &key) = 0;
|
||||
virtual KeyLength keyLength() const = 0;
|
||||
|
||||
virtual void update(const QSecureArray &in) = 0;
|
||||
virtual void final(QSecureArray *out) = 0;
|
||||
virtual void update(const SecureArray &in) = 0;
|
||||
virtual void final(SecureArray *out) = 0;
|
||||
|
||||
protected:
|
||||
KeyLength anyKeyLength() const
|
||||
@ -101,7 +101,7 @@ class QCA_EXPORT KDFContext : public BasicContext
|
||||
Q_OBJECT
|
||||
public:
|
||||
KDFContext(Provider *p, const QString &type) : BasicContext(p, type) {}
|
||||
virtual SymmetricKey makeKey(const QSecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount) = 0;
|
||||
virtual SymmetricKey makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount) = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT DLGroupContext : public Provider::Context
|
||||
@ -112,7 +112,7 @@ public:
|
||||
virtual QList<DLGroupSet> supportedGroupSets() const = 0;
|
||||
virtual bool isNull() const = 0;
|
||||
virtual void fetchGroup(DLGroupSet set, bool block) = 0;
|
||||
virtual void getResult(QBigInteger *p, QBigInteger *q, QBigInteger *g) const = 0;
|
||||
virtual void getResult(BigInteger *p, BigInteger *q, BigInteger *g) const = 0;
|
||||
|
||||
Q_SIGNALS:
|
||||
void finished();
|
||||
@ -132,15 +132,15 @@ public:
|
||||
|
||||
// encrypt/decrypt
|
||||
virtual int maximumEncryptSize(EncryptionAlgorithm alg) const;
|
||||
virtual QSecureArray encrypt(const QSecureArray &in, EncryptionAlgorithm alg);
|
||||
virtual bool decrypt(const QSecureArray &in, QSecureArray *out, EncryptionAlgorithm alg);
|
||||
virtual SecureArray encrypt(const SecureArray &in, EncryptionAlgorithm alg);
|
||||
virtual bool decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg);
|
||||
|
||||
// sign / verify
|
||||
virtual void startSign(SignatureAlgorithm alg, SignatureFormat format);
|
||||
virtual void startVerify(SignatureAlgorithm alg, SignatureFormat format);
|
||||
virtual void update(const QSecureArray &in);
|
||||
virtual QSecureArray endSign();
|
||||
virtual bool endVerify(const QSecureArray &sig);
|
||||
virtual void update(const SecureArray &in);
|
||||
virtual SecureArray endSign();
|
||||
virtual bool endVerify(const SecureArray &sig);
|
||||
|
||||
// key agreement
|
||||
virtual SymmetricKey deriveKey(const PKeyBase &theirs);
|
||||
@ -155,13 +155,13 @@ class QCA_EXPORT RSAContext : public PKeyBase
|
||||
public:
|
||||
RSAContext(Provider *p) : PKeyBase(p, "rsa") {}
|
||||
virtual void createPrivate(int bits, int exp, bool block) = 0;
|
||||
virtual void createPrivate(const QBigInteger &n, const QBigInteger &e, const QBigInteger &p, const QBigInteger &q, const QBigInteger &d) = 0;
|
||||
virtual void createPublic(const QBigInteger &n, const QBigInteger &e) = 0;
|
||||
virtual QBigInteger n() const = 0;
|
||||
virtual QBigInteger e() const = 0;
|
||||
virtual QBigInteger p() const = 0;
|
||||
virtual QBigInteger q() const = 0;
|
||||
virtual QBigInteger d() const = 0;
|
||||
virtual void createPrivate(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d) = 0;
|
||||
virtual void createPublic(const BigInteger &n, const BigInteger &e) = 0;
|
||||
virtual BigInteger n() const = 0;
|
||||
virtual BigInteger e() const = 0;
|
||||
virtual BigInteger p() const = 0;
|
||||
virtual BigInteger q() const = 0;
|
||||
virtual BigInteger d() const = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT DSAContext : public PKeyBase
|
||||
@ -170,11 +170,11 @@ class QCA_EXPORT DSAContext : public PKeyBase
|
||||
public:
|
||||
DSAContext(Provider *p) : PKeyBase(p, "dsa") {}
|
||||
virtual void createPrivate(const DLGroup &domain, bool block) = 0;
|
||||
virtual void createPrivate(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x) = 0;
|
||||
virtual void createPublic(const DLGroup &domain, const QBigInteger &y) = 0;
|
||||
virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
|
||||
virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
|
||||
virtual DLGroup domain() const = 0;
|
||||
virtual QBigInteger y() const = 0;
|
||||
virtual QBigInteger x() const = 0;
|
||||
virtual BigInteger y() const = 0;
|
||||
virtual BigInteger x() const = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT DHContext : public PKeyBase
|
||||
@ -183,11 +183,11 @@ class QCA_EXPORT DHContext : public PKeyBase
|
||||
public:
|
||||
DHContext(Provider *p) : PKeyBase(p, "dh") {}
|
||||
virtual void createPrivate(const DLGroup &domain, bool block) = 0;
|
||||
virtual void createPrivate(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x) = 0;
|
||||
virtual void createPublic(const DLGroup &domain, const QBigInteger &y) = 0;
|
||||
virtual void createPrivate(const DLGroup &domain, const BigInteger &y, const BigInteger &x) = 0;
|
||||
virtual void createPublic(const DLGroup &domain, const BigInteger &y) = 0;
|
||||
virtual DLGroup domain() const = 0;
|
||||
virtual QBigInteger y() const = 0;
|
||||
virtual QBigInteger x() const = 0;
|
||||
virtual BigInteger y() const = 0;
|
||||
virtual BigInteger x() const = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT PKeyContext : public BasicContext
|
||||
@ -206,14 +206,14 @@ public:
|
||||
virtual bool importKey(const PKeyBase *key) = 0;
|
||||
|
||||
// import / export
|
||||
virtual QSecureArray publicToDER() const;
|
||||
virtual SecureArray publicToDER() const;
|
||||
virtual QString publicToPEM() const;
|
||||
virtual ConvertResult publicFromDER(const QSecureArray &a);
|
||||
virtual ConvertResult publicFromDER(const SecureArray &a);
|
||||
virtual ConvertResult publicFromPEM(const QString &s);
|
||||
virtual QSecureArray privateToDER(const QSecureArray &passphrase, PBEAlgorithm pbe) const;
|
||||
virtual QString privateToPEM(const QSecureArray &passphrase, PBEAlgorithm pbe) const;
|
||||
virtual ConvertResult privateFromDER(const QSecureArray &a, const QSecureArray &passphrase);
|
||||
virtual ConvertResult privateFromPEM(const QString &s, const QSecureArray &passphrase);
|
||||
virtual SecureArray privateToDER(const SecureArray &passphrase, PBEAlgorithm pbe) const;
|
||||
virtual QString privateToPEM(const SecureArray &passphrase, PBEAlgorithm pbe) const;
|
||||
virtual ConvertResult privateFromDER(const SecureArray &a, const SecureArray &passphrase);
|
||||
virtual ConvertResult privateFromPEM(const QString &s, const SecureArray &passphrase);
|
||||
};
|
||||
|
||||
class QCA_EXPORT CertBase : public BasicContext
|
||||
@ -223,9 +223,9 @@ public:
|
||||
CertBase(Provider *p, const QString &type) : BasicContext(p, type) {}
|
||||
|
||||
// import / export
|
||||
virtual QSecureArray toDER() const = 0;
|
||||
virtual SecureArray toDER() const = 0;
|
||||
virtual QString toPEM() const = 0;
|
||||
virtual ConvertResult fromDER(const QSecureArray &a) = 0;
|
||||
virtual ConvertResult fromDER(const SecureArray &a) = 0;
|
||||
virtual ConvertResult fromPEM(const QString &s) = 0;
|
||||
};
|
||||
|
||||
@ -238,11 +238,11 @@ public:
|
||||
CertificateInfoOrdered issuer; // cert only
|
||||
Constraints constraints;
|
||||
QStringList policies;
|
||||
QBigInteger serial; // cert only
|
||||
BigInteger serial; // cert only
|
||||
bool isCA;
|
||||
bool isSelfSigned; // cert only
|
||||
int pathLimit;
|
||||
QSecureArray sig;
|
||||
SecureArray sig;
|
||||
SignatureAlgorithm sigalgo;
|
||||
QByteArray subjectId, issuerId; // cert only
|
||||
QString challenge; // csr only
|
||||
@ -256,7 +256,7 @@ public:
|
||||
int number;
|
||||
QDateTime thisUpdate, nextUpdate;
|
||||
QList<CRLEntry> revoked;
|
||||
QSecureArray sig;
|
||||
SecureArray sig;
|
||||
SignatureAlgorithm sigalgo;
|
||||
QByteArray issuerId;
|
||||
};
|
||||
@ -337,10 +337,10 @@ class QCA_EXPORT PKCS12Context : public BasicContext
|
||||
public:
|
||||
PKCS12Context(Provider *p) : BasicContext(p, "pkcs12") {}
|
||||
|
||||
virtual QByteArray toPKCS12(const QString &name, const QList<const CertContext*> &chain, const PKeyContext &priv, const QSecureArray &passphrase) const = 0;
|
||||
virtual QByteArray toPKCS12(const QString &name, const QList<const CertContext*> &chain, const PKeyContext &priv, const SecureArray &passphrase) const = 0;
|
||||
|
||||
// caller must delete
|
||||
virtual ConvertResult fromPKCS12(const QByteArray &in, const QSecureArray &passphrase, QString *name, QList<CertContext*> *chain, PKeyContext **priv) const = 0;
|
||||
virtual ConvertResult fromPKCS12(const QByteArray &in, const SecureArray &passphrase, QString *name, QList<CertContext*> *chain, PKeyContext **priv) const = 0;
|
||||
};
|
||||
|
||||
class QCA_EXPORT PGPKeyContextProps
|
||||
@ -363,9 +363,9 @@ public:
|
||||
|
||||
virtual const PGPKeyContextProps *props() const = 0;
|
||||
|
||||
virtual QSecureArray toBinary() const = 0;
|
||||
virtual SecureArray toBinary() const = 0;
|
||||
virtual QString toAscii() const = 0;
|
||||
virtual ConvertResult fromBinary(const QSecureArray &a) = 0;
|
||||
virtual ConvertResult fromBinary(const SecureArray &a) = 0;
|
||||
virtual ConvertResult fromAscii(const QString &s) = 0;
|
||||
};
|
||||
|
||||
@ -430,7 +430,7 @@ public:
|
||||
virtual QString writeEntry(int id, const PGPKey &key);
|
||||
virtual bool removeEntry(int id, const QString &entryId);
|
||||
|
||||
virtual void submitPassphrase(int id, int requestId, const QSecureArray &passphrase);
|
||||
virtual void submitPassphrase(int id, int requestId, const SecureArray &passphrase);
|
||||
virtual void rejectPassphraseRequest(int id, int requestId);
|
||||
|
||||
Q_SIGNALS:
|
||||
@ -612,7 +612,7 @@ public:
|
||||
|
||||
// call after NeedParams
|
||||
virtual SASL::Params clientParamsNeeded() const = 0;
|
||||
virtual void setClientParams(const QString *user, const QString *authzid, const QSecureArray *pass, const QString *realm) = 0;
|
||||
virtual void setClientParams(const QString *user, const QString *authzid, const SecureArray *pass, const QString *realm) = 0;
|
||||
|
||||
// call after AuthCheck
|
||||
virtual QString username() const = 0;
|
||||
|
@ -143,14 +143,14 @@ public:
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
// secure i/o
|
||||
QSecureArray readSecure(int bytes = -1);
|
||||
void writeSecure(const QSecureArray &a);
|
||||
SecureArray readSecure(int bytes = -1);
|
||||
void writeSecure(const SecureArray &a);
|
||||
#endif
|
||||
|
||||
QByteArray takeBytesToWrite();
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
QSecureArray takeBytesToWriteSecure();
|
||||
SecureArray takeBytesToWriteSecure();
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
|
@ -42,7 +42,7 @@ uchar Random::nextByte()
|
||||
return (uchar)(nextBytes(1)[0]);
|
||||
}
|
||||
|
||||
QSecureArray Random::nextBytes(int size)
|
||||
SecureArray Random::nextBytes(int size)
|
||||
{
|
||||
return static_cast<RandomContext *>(context())->nextBytes(size);
|
||||
}
|
||||
@ -56,13 +56,13 @@ uchar Random::randomChar()
|
||||
int Random::randomInt()
|
||||
{
|
||||
QMutexLocker locker(global_random_mutex());
|
||||
QSecureArray a = global_random()->nextBytes(sizeof(int));
|
||||
SecureArray a = global_random()->nextBytes(sizeof(int));
|
||||
int x;
|
||||
memcpy(&x, a.data(), a.size());
|
||||
return x;
|
||||
}
|
||||
|
||||
QSecureArray Random::randomArray(int size)
|
||||
SecureArray Random::randomArray(int size)
|
||||
{
|
||||
QMutexLocker locker(global_random_mutex());
|
||||
return global_random()->nextBytes(size);
|
||||
@ -81,14 +81,14 @@ void Hash::clear()
|
||||
static_cast<HashContext *>(context())->clear();
|
||||
}
|
||||
|
||||
void Hash::update(const QSecureArray &a)
|
||||
void Hash::update(const SecureArray &a)
|
||||
{
|
||||
static_cast<HashContext *>(context())->update(a);
|
||||
}
|
||||
|
||||
void Hash::update(const QByteArray &a)
|
||||
{
|
||||
update( QSecureArray( a ) );
|
||||
update( SecureArray( a ) );
|
||||
}
|
||||
|
||||
void Hash::update(const char *data, int len)
|
||||
@ -111,17 +111,17 @@ void Hash::update(QIODevice &file)
|
||||
update(buffer, len);
|
||||
}
|
||||
|
||||
QSecureArray Hash::final()
|
||||
SecureArray Hash::final()
|
||||
{
|
||||
return static_cast<HashContext *>(context())->final();
|
||||
}
|
||||
|
||||
QSecureArray Hash::hash(const QSecureArray &a)
|
||||
SecureArray Hash::hash(const SecureArray &a)
|
||||
{
|
||||
return process(a);
|
||||
}
|
||||
|
||||
QString Hash::hashToString(const QSecureArray &a)
|
||||
QString Hash::hashToString(const SecureArray &a)
|
||||
{
|
||||
return arrayToHex(hash(a));
|
||||
}
|
||||
@ -190,18 +190,18 @@ void Cipher::clear()
|
||||
static_cast<CipherContext *>(context())->setup(d->dir, d->key, d->iv);
|
||||
}
|
||||
|
||||
QSecureArray Cipher::update(const QSecureArray &a)
|
||||
SecureArray Cipher::update(const SecureArray &a)
|
||||
{
|
||||
QSecureArray out;
|
||||
SecureArray out;
|
||||
if(d->done)
|
||||
return out;
|
||||
d->ok = static_cast<CipherContext *>(context())->update(a, &out);
|
||||
return out;
|
||||
}
|
||||
|
||||
QSecureArray Cipher::final()
|
||||
SecureArray Cipher::final()
|
||||
{
|
||||
QSecureArray out;
|
||||
SecureArray out;
|
||||
if(d->done)
|
||||
return out;
|
||||
d->done = true;
|
||||
@ -274,7 +274,7 @@ public:
|
||||
SymmetricKey key;
|
||||
|
||||
bool done;
|
||||
QSecureArray buf;
|
||||
SecureArray buf;
|
||||
};
|
||||
|
||||
|
||||
@ -322,14 +322,14 @@ void MessageAuthenticationCode::clear()
|
||||
static_cast<MACContext *>(context())->setup(d->key);
|
||||
}
|
||||
|
||||
void MessageAuthenticationCode::update(const QSecureArray &a)
|
||||
void MessageAuthenticationCode::update(const SecureArray &a)
|
||||
{
|
||||
if(d->done)
|
||||
return;
|
||||
static_cast<MACContext *>(context())->update(a);
|
||||
}
|
||||
|
||||
QSecureArray MessageAuthenticationCode::final()
|
||||
SecureArray MessageAuthenticationCode::final()
|
||||
{
|
||||
if(!d->done)
|
||||
{
|
||||
@ -368,7 +368,7 @@ KeyDerivationFunction & KeyDerivationFunction::operator=(const KeyDerivationFunc
|
||||
return *this;
|
||||
}
|
||||
|
||||
SymmetricKey KeyDerivationFunction::makeKey(const QSecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount)
|
||||
SymmetricKey KeyDerivationFunction::makeKey(const SecureArray &secret, const InitializationVector &salt, unsigned int keyLength, unsigned int iterationCount)
|
||||
{
|
||||
return static_cast<KDFContext *>(context())->makeKey(secret, salt, keyLength, iterationCount);
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ bool stringToFile(const QString &fileName, const QString &content);
|
||||
bool stringFromFile(const QString &fileName, QString *s);
|
||||
bool arrayToFile(const QString &fileName, const QByteArray &content);
|
||||
bool arrayFromFile(const QString &fileName, QByteArray *a);
|
||||
bool ask_passphrase(const QString &fname, void *ptr, QSecureArray *answer);
|
||||
bool ask_passphrase(const QString &fname, void *ptr, SecureArray *answer);
|
||||
ProviderList allProviders();
|
||||
Provider *providerForName(const QString &name);
|
||||
bool use_asker_fallback(ConvertResult r);
|
||||
@ -604,7 +604,7 @@ public:
|
||||
QStringList policies;
|
||||
bool isCA;
|
||||
int pathLimit;
|
||||
QBigInteger serial;
|
||||
BigInteger serial;
|
||||
QDateTime start, end;
|
||||
|
||||
Private() : isCA(false), pathLimit(0)
|
||||
@ -691,7 +691,7 @@ int CertificateOptions::pathLimit() const
|
||||
return d->pathLimit;
|
||||
}
|
||||
|
||||
QBigInteger CertificateOptions::serialNumber() const
|
||||
BigInteger CertificateOptions::serialNumber() const
|
||||
{
|
||||
return d->serial;
|
||||
}
|
||||
@ -745,7 +745,7 @@ void CertificateOptions::setAsUser()
|
||||
d->pathLimit = 0;
|
||||
}
|
||||
|
||||
void CertificateOptions::setSerialNumber(const QBigInteger &i)
|
||||
void CertificateOptions::setSerialNumber(const BigInteger &i)
|
||||
{
|
||||
d->serial = i;
|
||||
}
|
||||
@ -927,7 +927,7 @@ QString Certificate::commonName() const
|
||||
return d->subjectInfoMap.value(CommonName);
|
||||
}
|
||||
|
||||
QBigInteger Certificate::serialNumber() const
|
||||
BigInteger Certificate::serialNumber() const
|
||||
{
|
||||
return static_cast<const CertContext *>(context())->props()->serial;
|
||||
}
|
||||
@ -1012,7 +1012,7 @@ Validity Certificate::validate(const CertificateCollection &trusted, const Certi
|
||||
return static_cast<const CertContext *>(context())->validate(trusted_list, untrusted_list, crl_list, u);*/
|
||||
}
|
||||
|
||||
QSecureArray Certificate::toDER() const
|
||||
SecureArray Certificate::toDER() const
|
||||
{
|
||||
return static_cast<const CertContext *>(context())->toDER();
|
||||
}
|
||||
@ -1027,7 +1027,7 @@ bool Certificate::toPEMFile(const QString &fileName) const
|
||||
return stringToFile(fileName, toPEM());
|
||||
}
|
||||
|
||||
Certificate Certificate::fromDER(const QSecureArray &a, ConvertResult *result, const QString &provider)
|
||||
Certificate Certificate::fromDER(const SecureArray &a, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
Certificate c;
|
||||
CertContext *cc = static_cast<CertContext *>(getContext("cert", provider));
|
||||
@ -1339,7 +1339,7 @@ bool CertificateRequest::operator==(const CertificateRequest &otherCsr) const
|
||||
return true;
|
||||
}
|
||||
|
||||
QSecureArray CertificateRequest::toDER() const
|
||||
SecureArray CertificateRequest::toDER() const
|
||||
{
|
||||
return static_cast<const CSRContext *>(context())->toDER();
|
||||
}
|
||||
@ -1354,7 +1354,7 @@ bool CertificateRequest::toPEMFile(const QString &fileName) const
|
||||
return stringToFile(fileName, toPEM());
|
||||
}
|
||||
|
||||
CertificateRequest CertificateRequest::fromDER(const QSecureArray &a, ConvertResult *result, const QString &provider)
|
||||
CertificateRequest CertificateRequest::fromDER(const SecureArray &a, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
CertificateRequest c;
|
||||
CSRContext *csr = static_cast<CSRContext *>(getContext("csr", provider));
|
||||
@ -1433,14 +1433,14 @@ CRLEntry::CRLEntry(const Certificate &c, Reason r)
|
||||
_reason = r;
|
||||
}
|
||||
|
||||
CRLEntry::CRLEntry(const QBigInteger serial, const QDateTime time, Reason r)
|
||||
CRLEntry::CRLEntry(const BigInteger serial, const QDateTime time, Reason r)
|
||||
{
|
||||
_serial = serial;
|
||||
_time = time;
|
||||
_reason = r;
|
||||
}
|
||||
|
||||
QBigInteger CRLEntry::serialNumber() const
|
||||
BigInteger CRLEntry::serialNumber() const
|
||||
{
|
||||
return _serial;
|
||||
}
|
||||
@ -1562,7 +1562,7 @@ QList<CRLEntry> CRL::revoked() const
|
||||
return static_cast<const CRLContext *>(context())->props()->revoked;
|
||||
}
|
||||
|
||||
QSecureArray CRL::signature() const
|
||||
SecureArray CRL::signature() const
|
||||
{
|
||||
return static_cast<const CRLContext *>(context())->props()->sig;
|
||||
}
|
||||
@ -1577,7 +1577,7 @@ QByteArray CRL::issuerKeyId() const
|
||||
return static_cast<const CRLContext *>(context())->props()->issuerId;
|
||||
}
|
||||
|
||||
QSecureArray CRL::toDER() const
|
||||
SecureArray CRL::toDER() const
|
||||
{
|
||||
return static_cast<const CRLContext *>(context())->toDER();
|
||||
}
|
||||
@ -1627,7 +1627,7 @@ bool CRL::operator==(const CRL &otherCrl) const
|
||||
|
||||
}
|
||||
|
||||
CRL CRL::fromDER(const QSecureArray &a, ConvertResult *result, const QString &provider)
|
||||
CRL CRL::fromDER(const SecureArray &a, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
CRL c;
|
||||
CRLContext *cc = static_cast<CRLContext *>(getContext("crl", provider));
|
||||
@ -1958,7 +1958,7 @@ KeyBundle::KeyBundle()
|
||||
{
|
||||
}
|
||||
|
||||
KeyBundle::KeyBundle(const QString &fileName, const QSecureArray &passphrase)
|
||||
KeyBundle::KeyBundle(const QString &fileName, const SecureArray &passphrase)
|
||||
:d(new Private)
|
||||
{
|
||||
*this = fromFile(fileName, passphrase, 0, QString());
|
||||
@ -2010,7 +2010,7 @@ void KeyBundle::setCertificateChainAndKey(const CertificateChain &c, const Priva
|
||||
d->key = key;
|
||||
}
|
||||
|
||||
QByteArray KeyBundle::toArray(const QSecureArray &passphrase, const QString &provider) const
|
||||
QByteArray KeyBundle::toArray(const SecureArray &passphrase, const QString &provider) const
|
||||
{
|
||||
PKCS12Context *pix = static_cast<PKCS12Context *>(getContext("pkcs12", provider));
|
||||
|
||||
@ -2023,12 +2023,12 @@ QByteArray KeyBundle::toArray(const QSecureArray &passphrase, const QString &pro
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool KeyBundle::toFile(const QString &fileName, const QSecureArray &passphrase, const QString &provider) const
|
||||
bool KeyBundle::toFile(const QString &fileName, const SecureArray &passphrase, const QString &provider) const
|
||||
{
|
||||
return arrayToFile(fileName, toArray(passphrase, provider));
|
||||
}
|
||||
|
||||
KeyBundle KeyBundle::fromArray(const QByteArray &a, const QSecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
KeyBundle KeyBundle::fromArray(const QByteArray &a, const SecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
QString name;
|
||||
QList<CertContext *> list;
|
||||
@ -2041,7 +2041,7 @@ KeyBundle KeyBundle::fromArray(const QByteArray &a, const QSecureArray &passphra
|
||||
// error converting without passphrase? maybe a passphrase is needed
|
||||
if(use_asker_fallback(r) && passphrase.isEmpty())
|
||||
{
|
||||
QSecureArray pass;
|
||||
SecureArray pass;
|
||||
if(ask_passphrase(QString(), 0, &pass))
|
||||
r = pix->fromPKCS12(a, pass, &name, &list, &kc);
|
||||
}
|
||||
@ -2063,7 +2063,7 @@ KeyBundle KeyBundle::fromArray(const QByteArray &a, const QSecureArray &passphra
|
||||
return bundle;
|
||||
}
|
||||
|
||||
KeyBundle KeyBundle::fromFile(const QString &fileName, const QSecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
KeyBundle KeyBundle::fromFile(const QString &fileName, const SecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
QByteArray der;
|
||||
if(!arrayFromFile(fileName, &der))
|
||||
@ -2152,7 +2152,7 @@ bool PGPKey::isTrusted() const
|
||||
return static_cast<const PGPKeyContext *>(context())->props()->isTrusted;
|
||||
}
|
||||
|
||||
QSecureArray PGPKey::toArray() const
|
||||
SecureArray PGPKey::toArray() const
|
||||
{
|
||||
return static_cast<const PGPKeyContext *>(context())->toBinary();
|
||||
}
|
||||
@ -2167,7 +2167,7 @@ bool PGPKey::toFile(const QString &fileName) const
|
||||
return stringToFile(fileName, toString());
|
||||
}
|
||||
|
||||
PGPKey PGPKey::fromArray(const QSecureArray &a, ConvertResult *result, const QString &provider)
|
||||
PGPKey PGPKey::fromArray(const SecureArray &a, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
PGPKey k;
|
||||
PGPKeyContext *kc = static_cast<PGPKeyContext *>(getContext("pgpkey", provider));
|
||||
@ -2217,7 +2217,7 @@ public:
|
||||
public:
|
||||
Type type;
|
||||
QString fileName, pem;
|
||||
QSecureArray der;
|
||||
SecureArray der;
|
||||
QByteArray kbder;
|
||||
};
|
||||
|
||||
@ -2240,15 +2240,15 @@ protected:
|
||||
virtual void run()
|
||||
{
|
||||
if(in.type == PKPEMFile)
|
||||
out.privateKey = PrivateKey::fromPEMFile(in.fileName, QSecureArray(), &out.convertResult);
|
||||
out.privateKey = PrivateKey::fromPEMFile(in.fileName, SecureArray(), &out.convertResult);
|
||||
else if(in.type == PKPEM)
|
||||
out.privateKey = PrivateKey::fromPEM(in.pem, QSecureArray(), &out.convertResult);
|
||||
out.privateKey = PrivateKey::fromPEM(in.pem, SecureArray(), &out.convertResult);
|
||||
else if(in.type == PKDER)
|
||||
out.privateKey = PrivateKey::fromDER(in.der, QSecureArray(), &out.convertResult);
|
||||
out.privateKey = PrivateKey::fromDER(in.der, SecureArray(), &out.convertResult);
|
||||
else if(in.type == KBDERFile)
|
||||
out.keyBundle = KeyBundle::fromFile(in.fileName, QSecureArray(), &out.convertResult);
|
||||
out.keyBundle = KeyBundle::fromFile(in.fileName, SecureArray(), &out.convertResult);
|
||||
else if(in.type == KBDER)
|
||||
out.keyBundle = KeyBundle::fromArray(in.kbder, QSecureArray(), &out.convertResult);
|
||||
out.keyBundle = KeyBundle::fromArray(in.kbder, SecureArray(), &out.convertResult);
|
||||
}
|
||||
};
|
||||
|
||||
@ -2331,7 +2331,7 @@ void KeyLoader::loadPrivateKeyFromPEM(const QString &s)
|
||||
d->start();
|
||||
}
|
||||
|
||||
void KeyLoader::loadPrivateKeyFromDER(const QSecureArray &a)
|
||||
void KeyLoader::loadPrivateKeyFromDER(const SecureArray &a)
|
||||
{
|
||||
Q_ASSERT(!d->active);
|
||||
if(d->active)
|
||||
|
@ -651,7 +651,7 @@ void setAppName(const QString &s)
|
||||
global->app_name = s;
|
||||
}
|
||||
|
||||
QString arrayToHex(const QSecureArray &a)
|
||||
QString arrayToHex(const SecureArray &a)
|
||||
{
|
||||
return Hex().arrayToString(a);
|
||||
}
|
||||
@ -843,12 +843,12 @@ int PKeyBase::maximumEncryptSize(EncryptionAlgorithm) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
QSecureArray PKeyBase::encrypt(const QSecureArray &, EncryptionAlgorithm)
|
||||
SecureArray PKeyBase::encrypt(const SecureArray &, EncryptionAlgorithm)
|
||||
{
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
}
|
||||
|
||||
bool PKeyBase::decrypt(const QSecureArray &, QSecureArray *, EncryptionAlgorithm)
|
||||
bool PKeyBase::decrypt(const SecureArray &, SecureArray *, EncryptionAlgorithm)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -861,16 +861,16 @@ void PKeyBase::startVerify(SignatureAlgorithm, SignatureFormat)
|
||||
{
|
||||
}
|
||||
|
||||
void PKeyBase::update(const QSecureArray &)
|
||||
void PKeyBase::update(const SecureArray &)
|
||||
{
|
||||
}
|
||||
|
||||
QSecureArray PKeyBase::endSign()
|
||||
SecureArray PKeyBase::endSign()
|
||||
{
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
}
|
||||
|
||||
bool PKeyBase::endVerify(const QSecureArray &)
|
||||
bool PKeyBase::endVerify(const SecureArray &)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -883,9 +883,9 @@ SymmetricKey PKeyBase::deriveKey(const PKeyBase &)
|
||||
//----------------------------------------------------------------------------
|
||||
// PKeyContext
|
||||
//----------------------------------------------------------------------------
|
||||
QSecureArray PKeyContext::publicToDER() const
|
||||
SecureArray PKeyContext::publicToDER() const
|
||||
{
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
}
|
||||
|
||||
QString PKeyContext::publicToPEM() const
|
||||
@ -893,7 +893,7 @@ QString PKeyContext::publicToPEM() const
|
||||
return QString();
|
||||
}
|
||||
|
||||
ConvertResult PKeyContext::publicFromDER(const QSecureArray &)
|
||||
ConvertResult PKeyContext::publicFromDER(const SecureArray &)
|
||||
{
|
||||
return ErrorDecode;
|
||||
}
|
||||
@ -903,22 +903,22 @@ ConvertResult PKeyContext::publicFromPEM(const QString &)
|
||||
return ErrorDecode;
|
||||
}
|
||||
|
||||
QSecureArray PKeyContext::privateToDER(const QSecureArray &, PBEAlgorithm) const
|
||||
SecureArray PKeyContext::privateToDER(const SecureArray &, PBEAlgorithm) const
|
||||
{
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
}
|
||||
|
||||
QString PKeyContext::privateToPEM(const QSecureArray &, PBEAlgorithm) const
|
||||
QString PKeyContext::privateToPEM(const SecureArray &, PBEAlgorithm) const
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
ConvertResult PKeyContext::privateFromDER(const QSecureArray &, const QSecureArray &)
|
||||
ConvertResult PKeyContext::privateFromDER(const SecureArray &, const SecureArray &)
|
||||
{
|
||||
return ErrorDecode;
|
||||
}
|
||||
|
||||
ConvertResult PKeyContext::privateFromPEM(const QString &, const QSecureArray &)
|
||||
ConvertResult PKeyContext::privateFromPEM(const QString &, const SecureArray &)
|
||||
{
|
||||
return ErrorDecode;
|
||||
}
|
||||
@ -1021,7 +1021,7 @@ bool KeyStoreListContext::removeEntry(int, const QString &)
|
||||
return false;
|
||||
}
|
||||
|
||||
void KeyStoreListContext::submitPassphrase(int, int, const QSecureArray &)
|
||||
void KeyStoreListContext::submitPassphrase(int, int, const SecureArray &)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1054,7 +1054,7 @@ BufferedComputation::~BufferedComputation()
|
||||
{
|
||||
}
|
||||
|
||||
QSecureArray BufferedComputation::process(const QSecureArray &a)
|
||||
SecureArray BufferedComputation::process(const SecureArray &a)
|
||||
{
|
||||
clear();
|
||||
update(a);
|
||||
@ -1068,15 +1068,15 @@ Filter::~Filter()
|
||||
{
|
||||
}
|
||||
|
||||
QSecureArray Filter::process(const QSecureArray &a)
|
||||
SecureArray Filter::process(const SecureArray &a)
|
||||
{
|
||||
clear();
|
||||
QSecureArray buf = update(a);
|
||||
SecureArray buf = update(a);
|
||||
if(!ok())
|
||||
return QSecureArray();
|
||||
QSecureArray fin = final();
|
||||
return SecureArray();
|
||||
SecureArray fin = final();
|
||||
if(!ok())
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
int oldsize = buf.size();
|
||||
buf.resize(oldsize + fin.size());
|
||||
memcpy(buf.data() + oldsize, fin.data(), fin.size());
|
||||
@ -1207,14 +1207,14 @@ SymmetricKey::SymmetricKey(int size)
|
||||
set(Random::randomArray(size));
|
||||
}
|
||||
|
||||
SymmetricKey::SymmetricKey(const QSecureArray &a)
|
||||
SymmetricKey::SymmetricKey(const SecureArray &a)
|
||||
{
|
||||
set(a);
|
||||
}
|
||||
|
||||
SymmetricKey::SymmetricKey(const QByteArray &a)
|
||||
{
|
||||
set(QSecureArray(a));
|
||||
set(SecureArray(a));
|
||||
}
|
||||
|
||||
/* from libgcrypt-1.2.0 */
|
||||
@ -1290,7 +1290,7 @@ bool SymmetricKey::isWeakDESKey()
|
||||
{
|
||||
if(size() != 8)
|
||||
return false; // dubious
|
||||
QSecureArray workingCopy(8);
|
||||
SecureArray workingCopy(8);
|
||||
// clear parity bits
|
||||
for(uint i = 0; i < 8; i++)
|
||||
workingCopy[i] = (data()[i]) & 0xfe;
|
||||
@ -1315,14 +1315,14 @@ InitializationVector::InitializationVector(int size)
|
||||
set(Random::randomArray(size));
|
||||
}
|
||||
|
||||
InitializationVector::InitializationVector(const QSecureArray &a)
|
||||
InitializationVector::InitializationVector(const SecureArray &a)
|
||||
{
|
||||
set(a);
|
||||
}
|
||||
|
||||
InitializationVector::InitializationVector(const QByteArray &a)
|
||||
{
|
||||
set(QSecureArray(a));
|
||||
set(SecureArray(a));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
@ -1461,13 +1461,13 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void set_accepted(const QSecureArray &password) = 0;
|
||||
virtual void set_accepted(const SecureArray &password) = 0;
|
||||
virtual void set_rejected() = 0;
|
||||
};
|
||||
|
||||
static void handler_add(HandlerBase *h, int pos = -1);
|
||||
static void handler_remove(HandlerBase *h);
|
||||
static void handler_accept(HandlerBase *h, int id, const QSecureArray &password);
|
||||
static void handler_accept(HandlerBase *h, int id, const SecureArray &password);
|
||||
static void handler_reject(HandlerBase *h, int id);
|
||||
static bool asker_ask(AskerBase *a, const Event &e);
|
||||
static void asker_cancel(AskerBase *a);
|
||||
@ -1504,7 +1504,7 @@ public:
|
||||
EventGlobal()
|
||||
{
|
||||
qRegisterMetaType<Event>("QCA::Event");
|
||||
qRegisterMetaType<QSecureArray>("QSecureArray");
|
||||
qRegisterMetaType<SecureArray>("QCA::SecureArray");
|
||||
next_id = 0;
|
||||
}
|
||||
|
||||
@ -1643,7 +1643,7 @@ void handler_remove(HandlerBase *h)
|
||||
}
|
||||
}
|
||||
|
||||
void handler_accept(HandlerBase *h, int id, const QSecureArray &password)
|
||||
void handler_accept(HandlerBase *h, int id, const SecureArray &password)
|
||||
{
|
||||
QMutexLocker locker(g_event_mutex());
|
||||
Q_ASSERT(g_event);
|
||||
@ -1780,7 +1780,7 @@ void EventHandler::start()
|
||||
handler_add(d);
|
||||
}
|
||||
|
||||
void EventHandler::submitPassword(int id, const QSecureArray &password)
|
||||
void EventHandler::submitPassword(int id, const SecureArray &password)
|
||||
{
|
||||
if(!d->activeIds.contains(id))
|
||||
return;
|
||||
@ -1795,7 +1795,7 @@ void EventHandler::tokenOkay(int id)
|
||||
return;
|
||||
|
||||
d->activeIds.removeAll(id);
|
||||
handler_accept(d, id, QSecureArray());
|
||||
handler_accept(d, id, SecureArray());
|
||||
}
|
||||
|
||||
void EventHandler::reject(int id)
|
||||
@ -1824,7 +1824,7 @@ public:
|
||||
QWaitCondition w;
|
||||
|
||||
bool accepted;
|
||||
QSecureArray password;
|
||||
SecureArray password;
|
||||
bool waiting;
|
||||
bool done;
|
||||
|
||||
@ -1868,7 +1868,7 @@ public:
|
||||
asker_cancel(this);
|
||||
}
|
||||
|
||||
virtual void set_accepted(const QSecureArray &_password)
|
||||
virtual void set_accepted(const SecureArray &_password)
|
||||
{
|
||||
QMutexLocker locker(&m);
|
||||
accepted = true;
|
||||
@ -1957,7 +1957,7 @@ bool PasswordAsker::accepted() const
|
||||
return d->accepted;
|
||||
}
|
||||
|
||||
QSecureArray PasswordAsker::password() const
|
||||
SecureArray PasswordAsker::password() const
|
||||
{
|
||||
return d->password;
|
||||
}
|
||||
|
@ -44,9 +44,9 @@ public:
|
||||
return new DefaultRandomContext(provider());
|
||||
}
|
||||
|
||||
virtual QSecureArray nextBytes(int size)
|
||||
virtual SecureArray nextBytes(int size)
|
||||
{
|
||||
QSecureArray buf(size);
|
||||
SecureArray buf(size);
|
||||
for(int n = 0; n < (int)buf.size(); ++n)
|
||||
buf[n] = (char)rand();
|
||||
return buf;
|
||||
@ -127,7 +127,7 @@ typedef quint32 md5_word_t; /* 32-bit word */
|
||||
|
||||
/* Define the state of the MD5 Algorithm. */
|
||||
struct md5_state_t {
|
||||
QSecureArray sbuf;
|
||||
SecureArray sbuf;
|
||||
md5_word_t *count; // 2 /* message length in bits, lsw first */
|
||||
md5_word_t *abcd; // 4 /* digest buffer */
|
||||
md5_byte_t *buf; // 64 /* accumulate block */
|
||||
@ -245,7 +245,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
|
||||
|
||||
/* Define storage for little-endian or both types of CPUs. */
|
||||
// possible FIXME: does xbuf really need to be secured?
|
||||
QSecureArray sxbuf(16 * sizeof(md5_word_t));
|
||||
SecureArray sxbuf(16 * sizeof(md5_word_t));
|
||||
md5_word_t *xbuf = (md5_word_t *)sxbuf.data();
|
||||
const md5_word_t *X;
|
||||
|
||||
@ -485,14 +485,14 @@ public:
|
||||
md5_init(&md5);
|
||||
}
|
||||
|
||||
virtual void update(const QSecureArray &in)
|
||||
virtual void update(const SecureArray &in)
|
||||
{
|
||||
md5_append(&md5, (const md5_byte_t *)in.data(), in.size());
|
||||
}
|
||||
|
||||
virtual QSecureArray final()
|
||||
virtual SecureArray final()
|
||||
{
|
||||
QSecureArray b(16);
|
||||
SecureArray b(16);
|
||||
md5_finish(&md5, (md5_byte_t *)b.data());
|
||||
return b;
|
||||
}
|
||||
@ -518,7 +518,7 @@ public:
|
||||
|
||||
struct SHA1_CONTEXT
|
||||
{
|
||||
QSecureArray sbuf;
|
||||
SecureArray sbuf;
|
||||
quint32 *state; // 5
|
||||
quint32 *count; // 2
|
||||
unsigned char *buffer; // 64
|
||||
@ -576,14 +576,14 @@ public:
|
||||
sha1_init(&_context);
|
||||
}
|
||||
|
||||
virtual void update(const QSecureArray &in)
|
||||
virtual void update(const SecureArray &in)
|
||||
{
|
||||
sha1_update(&_context, (unsigned char *)in.data(), (unsigned int)in.size());
|
||||
}
|
||||
|
||||
virtual QSecureArray final()
|
||||
virtual SecureArray final()
|
||||
{
|
||||
QSecureArray b(20);
|
||||
SecureArray b(20);
|
||||
sha1_final((unsigned char *)b.data(), &_context);
|
||||
return b;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ bool arrayFromFile(const QString &fileName, QByteArray *a)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ask_passphrase(const QString &fname, void *ptr, QSecureArray *answer)
|
||||
bool ask_passphrase(const QString &fname, void *ptr, SecureArray *answer)
|
||||
{
|
||||
PasswordAsker asker;
|
||||
asker.ask(Event::StylePassphrase, fname, ptr);
|
||||
@ -169,7 +169,7 @@ class Getter_PublicKey
|
||||
{
|
||||
public:
|
||||
// DER
|
||||
static ConvertResult fromData(PKeyContext *c, const QSecureArray &in)
|
||||
static ConvertResult fromData(PKeyContext *c, const SecureArray &in)
|
||||
{
|
||||
return c->publicFromDER(in);
|
||||
}
|
||||
@ -180,7 +180,7 @@ public:
|
||||
return c->publicFromPEM(in);
|
||||
}
|
||||
|
||||
static PublicKey getKey(Provider *p, const I &in, const QSecureArray &, ConvertResult *result)
|
||||
static PublicKey getKey(Provider *p, const I &in, const SecureArray &, ConvertResult *result)
|
||||
{
|
||||
PublicKey k;
|
||||
PKeyContext *c = static_cast<PKeyContext *>(getContext("pkey", p));
|
||||
@ -204,18 +204,18 @@ class Getter_PrivateKey
|
||||
{
|
||||
public:
|
||||
// DER
|
||||
static ConvertResult fromData(PKeyContext *c, const QSecureArray &in, const QSecureArray &passphrase)
|
||||
static ConvertResult fromData(PKeyContext *c, const SecureArray &in, const SecureArray &passphrase)
|
||||
{
|
||||
return c->privateFromDER(in, passphrase);
|
||||
}
|
||||
|
||||
// PEM
|
||||
static ConvertResult fromData(PKeyContext *c, const QString &in, const QSecureArray &passphrase)
|
||||
static ConvertResult fromData(PKeyContext *c, const QString &in, const SecureArray &passphrase)
|
||||
{
|
||||
return c->privateFromPEM(in, passphrase);
|
||||
}
|
||||
|
||||
static PrivateKey getKey(Provider *p, const I &in, const QSecureArray &passphrase, ConvertResult *result)
|
||||
static PrivateKey getKey(Provider *p, const I &in, const SecureArray &passphrase, ConvertResult *result)
|
||||
{
|
||||
PrivateKey k;
|
||||
PKeyContext *c = static_cast<PKeyContext *>(getContext("pkey", p));
|
||||
@ -299,7 +299,7 @@ QList<T> getList(const QString &provider)
|
||||
}
|
||||
|
||||
template <typename T, typename G, typename I>
|
||||
T getKey(const QString &provider, const I &in, const QSecureArray &passphrase, ConvertResult *result)
|
||||
T getKey(const QString &provider, const I &in, const SecureArray &passphrase, ConvertResult *result)
|
||||
{
|
||||
T k;
|
||||
|
||||
@ -379,11 +379,11 @@ QByteArray get_hash_id(const QString &name)
|
||||
return QByteArray();
|
||||
}
|
||||
|
||||
QSecureArray emsa3Encode(const QString &hashName, const QSecureArray &digest, int size)
|
||||
SecureArray emsa3Encode(const QString &hashName, const SecureArray &digest, int size)
|
||||
{
|
||||
QByteArray hash_id = get_hash_id(hashName);
|
||||
if(hash_id.isEmpty())
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
|
||||
// logic adapted from Botan
|
||||
int basesize = hash_id.size() + digest.size() + 2;
|
||||
@ -391,9 +391,9 @@ QSecureArray emsa3Encode(const QString &hashName, const QSecureArray &digest, in
|
||||
size = basesize + 1; // default to 1-byte pad
|
||||
int padlen = size - basesize;
|
||||
if(padlen < 1)
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
|
||||
QSecureArray out(size, 0xff); // pad with 0xff
|
||||
SecureArray out(size, 0xff); // pad with 0xff
|
||||
out[0] = 0x01;
|
||||
out[padlen + 1] = 0x00;
|
||||
int at = padlen + 2;
|
||||
@ -409,9 +409,9 @@ QSecureArray emsa3Encode(const QString &hashName, const QSecureArray &digest, in
|
||||
class DLGroup::Private
|
||||
{
|
||||
public:
|
||||
QBigInteger p, q, g;
|
||||
BigInteger p, q, g;
|
||||
|
||||
Private(const QBigInteger &p1, const QBigInteger &q1, const QBigInteger &g1)
|
||||
Private(const BigInteger &p1, const BigInteger &q1, const BigInteger &g1)
|
||||
:p(p1), q(q1), g(g1)
|
||||
{
|
||||
}
|
||||
@ -422,12 +422,12 @@ DLGroup::DLGroup()
|
||||
d = 0;
|
||||
}
|
||||
|
||||
DLGroup::DLGroup(const QBigInteger &p, const QBigInteger &q, const QBigInteger &g)
|
||||
DLGroup::DLGroup(const BigInteger &p, const BigInteger &q, const BigInteger &g)
|
||||
{
|
||||
d = new Private(p, q, g);
|
||||
}
|
||||
|
||||
DLGroup::DLGroup(const QBigInteger &p, const QBigInteger &g)
|
||||
DLGroup::DLGroup(const BigInteger &p, const BigInteger &g)
|
||||
{
|
||||
d = new Private(p, 0, g);
|
||||
}
|
||||
@ -464,17 +464,17 @@ bool DLGroup::isNull() const
|
||||
return (d ? false: true);
|
||||
}
|
||||
|
||||
QBigInteger DLGroup::p() const
|
||||
BigInteger DLGroup::p() const
|
||||
{
|
||||
return d->p;
|
||||
}
|
||||
|
||||
QBigInteger DLGroup::q() const
|
||||
BigInteger DLGroup::q() const
|
||||
{
|
||||
return d->q;
|
||||
}
|
||||
|
||||
QBigInteger DLGroup::g() const
|
||||
BigInteger DLGroup::g() const
|
||||
{
|
||||
return d->g;
|
||||
}
|
||||
@ -734,7 +734,7 @@ int PublicKey::maximumEncryptSize(EncryptionAlgorithm alg) const
|
||||
return static_cast<const PKeyContext *>(context())->key()->maximumEncryptSize(alg);
|
||||
}
|
||||
|
||||
QSecureArray PublicKey::encrypt(const QSecureArray &a, EncryptionAlgorithm alg)
|
||||
SecureArray PublicKey::encrypt(const SecureArray &a, EncryptionAlgorithm alg)
|
||||
{
|
||||
return static_cast<PKeyContext *>(context())->key()->encrypt(a, alg);
|
||||
}
|
||||
@ -746,26 +746,26 @@ void PublicKey::startVerify(SignatureAlgorithm alg, SignatureFormat format)
|
||||
static_cast<PKeyContext *>(context())->key()->startVerify(alg, format);
|
||||
}
|
||||
|
||||
void PublicKey::update(const QSecureArray &a)
|
||||
void PublicKey::update(const SecureArray &a)
|
||||
{
|
||||
static_cast<PKeyContext *>(context())->key()->update(a);
|
||||
}
|
||||
|
||||
bool PublicKey::validSignature(const QSecureArray &sig)
|
||||
bool PublicKey::validSignature(const SecureArray &sig)
|
||||
{
|
||||
return static_cast<PKeyContext *>(context())->key()->endVerify(sig);
|
||||
}
|
||||
|
||||
bool PublicKey::verifyMessage(const QSecureArray &a, const QSecureArray &sig, SignatureAlgorithm alg, SignatureFormat format)
|
||||
bool PublicKey::verifyMessage(const SecureArray &a, const SecureArray &sig, SignatureAlgorithm alg, SignatureFormat format)
|
||||
{
|
||||
startVerify(alg, format);
|
||||
update(a);
|
||||
return validSignature(sig);
|
||||
}
|
||||
|
||||
QSecureArray PublicKey::toDER() const
|
||||
SecureArray PublicKey::toDER() const
|
||||
{
|
||||
QSecureArray out;
|
||||
SecureArray out;
|
||||
Provider *p = providerForIOType(type());
|
||||
if(!p)
|
||||
return out;
|
||||
@ -810,14 +810,14 @@ bool PublicKey::toPEMFile(const QString &fileName) const
|
||||
return stringToFile(fileName, toPEM());
|
||||
}
|
||||
|
||||
PublicKey PublicKey::fromDER(const QSecureArray &a, ConvertResult *result, const QString &provider)
|
||||
PublicKey PublicKey::fromDER(const SecureArray &a, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
return getKey<PublicKey, Getter_PublicKey<QSecureArray>, QSecureArray>(provider, a, QSecureArray(), result);
|
||||
return getKey<PublicKey, Getter_PublicKey<SecureArray>, SecureArray>(provider, a, SecureArray(), result);
|
||||
}
|
||||
|
||||
PublicKey PublicKey::fromPEM(const QString &s, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
return getKey<PublicKey, Getter_PublicKey<QString>, QString>(provider, s, QSecureArray(), result);
|
||||
return getKey<PublicKey, Getter_PublicKey<QString>, QString>(provider, s, SecureArray(), result);
|
||||
}
|
||||
|
||||
PublicKey PublicKey::fromPEMFile(const QString &fileName, ConvertResult *result, const QString &provider)
|
||||
@ -844,7 +844,7 @@ PrivateKey::PrivateKey(const QString &type, const QString &provider)
|
||||
{
|
||||
}
|
||||
|
||||
PrivateKey::PrivateKey(const QString &fileName, const QSecureArray &passphrase)
|
||||
PrivateKey::PrivateKey(const QString &fileName, const SecureArray &passphrase)
|
||||
{
|
||||
*this = fromPEMFile(fileName, passphrase, 0, QString());
|
||||
}
|
||||
@ -874,7 +874,7 @@ bool PrivateKey::canSign() const
|
||||
return (isRSA() || isDSA());
|
||||
}
|
||||
|
||||
bool PrivateKey::decrypt(const QSecureArray &in, QSecureArray *out, EncryptionAlgorithm alg)
|
||||
bool PrivateKey::decrypt(const SecureArray &in, SecureArray *out, EncryptionAlgorithm alg)
|
||||
{
|
||||
return static_cast<PKeyContext *>(context())->key()->decrypt(in, out, alg);
|
||||
}
|
||||
@ -886,17 +886,17 @@ void PrivateKey::startSign(SignatureAlgorithm alg, SignatureFormat format)
|
||||
static_cast<PKeyContext *>(context())->key()->startSign(alg, format);
|
||||
}
|
||||
|
||||
void PrivateKey::update(const QSecureArray &a)
|
||||
void PrivateKey::update(const SecureArray &a)
|
||||
{
|
||||
static_cast<PKeyContext *>(context())->key()->update(a);
|
||||
}
|
||||
|
||||
QSecureArray PrivateKey::signature()
|
||||
SecureArray PrivateKey::signature()
|
||||
{
|
||||
return static_cast<PKeyContext *>(context())->key()->endSign();
|
||||
}
|
||||
|
||||
QSecureArray PrivateKey::signMessage(const QSecureArray &a, SignatureAlgorithm alg, SignatureFormat format)
|
||||
SecureArray PrivateKey::signMessage(const SecureArray &a, SignatureAlgorithm alg, SignatureFormat format)
|
||||
{
|
||||
startSign(alg, format);
|
||||
update(a);
|
||||
@ -914,9 +914,9 @@ QList<PBEAlgorithm> PrivateKey::supportedPBEAlgorithms(const QString &provider)
|
||||
return getList<PBEAlgorithm, Getter_PBE>(provider);
|
||||
}
|
||||
|
||||
QSecureArray PrivateKey::toDER(const QSecureArray &passphrase, PBEAlgorithm pbe) const
|
||||
SecureArray PrivateKey::toDER(const SecureArray &passphrase, PBEAlgorithm pbe) const
|
||||
{
|
||||
QSecureArray out;
|
||||
SecureArray out;
|
||||
if(pbe == PBEDefault)
|
||||
pbe = get_pbe_default();
|
||||
Provider *p = providerForPBE(pbe, type());
|
||||
@ -937,7 +937,7 @@ QSecureArray PrivateKey::toDER(const QSecureArray &passphrase, PBEAlgorithm pbe)
|
||||
return out;
|
||||
}
|
||||
|
||||
QString PrivateKey::toPEM(const QSecureArray &passphrase, PBEAlgorithm pbe) const
|
||||
QString PrivateKey::toPEM(const SecureArray &passphrase, PBEAlgorithm pbe) const
|
||||
{
|
||||
QString out;
|
||||
if(pbe == PBEDefault)
|
||||
@ -960,30 +960,30 @@ QString PrivateKey::toPEM(const QSecureArray &passphrase, PBEAlgorithm pbe) cons
|
||||
return out;
|
||||
}
|
||||
|
||||
bool PrivateKey::toPEMFile(const QString &fileName, const QSecureArray &passphrase, PBEAlgorithm pbe) const
|
||||
bool PrivateKey::toPEMFile(const QString &fileName, const SecureArray &passphrase, PBEAlgorithm pbe) const
|
||||
{
|
||||
return stringToFile(fileName, toPEM(passphrase, pbe));
|
||||
}
|
||||
|
||||
PrivateKey PrivateKey::fromDER(const QSecureArray &a, const QSecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
PrivateKey PrivateKey::fromDER(const SecureArray &a, const SecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
PrivateKey out;
|
||||
ConvertResult r;
|
||||
out = getKey<PrivateKey, Getter_PrivateKey<QSecureArray>, QSecureArray>(provider, a, passphrase, &r);
|
||||
out = getKey<PrivateKey, Getter_PrivateKey<SecureArray>, SecureArray>(provider, a, passphrase, &r);
|
||||
|
||||
// error converting without passphrase? maybe a passphrase is needed
|
||||
if(use_asker_fallback(r) && passphrase.isEmpty())
|
||||
{
|
||||
QSecureArray pass;
|
||||
SecureArray pass;
|
||||
if(ask_passphrase(QString(), 0, &pass))
|
||||
out = getKey<PrivateKey, Getter_PrivateKey<QSecureArray>, QSecureArray>(provider, a, pass, &r);
|
||||
out = getKey<PrivateKey, Getter_PrivateKey<SecureArray>, SecureArray>(provider, a, pass, &r);
|
||||
}
|
||||
if(result)
|
||||
*result = r;
|
||||
return out;
|
||||
}
|
||||
|
||||
PrivateKey PrivateKey::fromPEM(const QString &s, const QSecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
PrivateKey PrivateKey::fromPEM(const QString &s, const SecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
PrivateKey out;
|
||||
ConvertResult r;
|
||||
@ -992,7 +992,7 @@ PrivateKey PrivateKey::fromPEM(const QString &s, const QSecureArray &passphrase,
|
||||
// error converting without passphrase? maybe a passphrase is needed
|
||||
if(use_asker_fallback(r) && passphrase.isEmpty())
|
||||
{
|
||||
QSecureArray pass;
|
||||
SecureArray pass;
|
||||
if(ask_passphrase(QString(), 0, &pass))
|
||||
out = getKey<PrivateKey, Getter_PrivateKey<QString>, QString>(provider, s, pass, &r);
|
||||
}
|
||||
@ -1001,7 +1001,7 @@ PrivateKey PrivateKey::fromPEM(const QString &s, const QSecureArray &passphrase,
|
||||
return out;
|
||||
}
|
||||
|
||||
PrivateKey PrivateKey::fromPEMFile(const QString &fileName, const QSecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
PrivateKey PrivateKey::fromPEMFile(const QString &fileName, const SecureArray &passphrase, ConvertResult *result, const QString &provider)
|
||||
{
|
||||
QString pem;
|
||||
if(!stringFromFile(fileName, &pem))
|
||||
@ -1075,7 +1075,7 @@ public slots:
|
||||
{
|
||||
if(!dc->isNull())
|
||||
{
|
||||
QBigInteger p, q, g;
|
||||
BigInteger p, q, g;
|
||||
dc->getResult(&p, &q, &g);
|
||||
group = DLGroup(p, q, g);
|
||||
}
|
||||
@ -1238,7 +1238,7 @@ RSAPublicKey::RSAPublicKey()
|
||||
{
|
||||
}
|
||||
|
||||
RSAPublicKey::RSAPublicKey(const QBigInteger &n, const QBigInteger &e, const QString &provider)
|
||||
RSAPublicKey::RSAPublicKey(const BigInteger &n, const BigInteger &e, const QString &provider)
|
||||
{
|
||||
RSAContext *k = static_cast<RSAContext *>(getContext("rsa", provider));
|
||||
k->createPublic(n, e);
|
||||
@ -1252,12 +1252,12 @@ RSAPublicKey::RSAPublicKey(const RSAPrivateKey &k)
|
||||
{
|
||||
}
|
||||
|
||||
QBigInteger RSAPublicKey::n() const
|
||||
BigInteger RSAPublicKey::n() const
|
||||
{
|
||||
return static_cast<const RSAContext *>(static_cast<const PKeyContext *>(context())->key())->n();
|
||||
}
|
||||
|
||||
QBigInteger RSAPublicKey::e() const
|
||||
BigInteger RSAPublicKey::e() const
|
||||
{
|
||||
return static_cast<const RSAContext *>(static_cast<const PKeyContext *>(context())->key())->e();
|
||||
}
|
||||
@ -1269,7 +1269,7 @@ RSAPrivateKey::RSAPrivateKey()
|
||||
{
|
||||
}
|
||||
|
||||
RSAPrivateKey::RSAPrivateKey(const QBigInteger &n, const QBigInteger &e, const QBigInteger &p, const QBigInteger &q, const QBigInteger &d, const QString &provider)
|
||||
RSAPrivateKey::RSAPrivateKey(const BigInteger &n, const BigInteger &e, const BigInteger &p, const BigInteger &q, const BigInteger &d, const QString &provider)
|
||||
{
|
||||
RSAContext *k = static_cast<RSAContext *>(getContext("rsa", provider));
|
||||
k->createPrivate(n, e, p, q, d);
|
||||
@ -1278,27 +1278,27 @@ RSAPrivateKey::RSAPrivateKey(const QBigInteger &n, const QBigInteger &e, const Q
|
||||
change(c);
|
||||
}
|
||||
|
||||
QBigInteger RSAPrivateKey::n() const
|
||||
BigInteger RSAPrivateKey::n() const
|
||||
{
|
||||
return static_cast<const RSAContext *>(static_cast<const PKeyContext *>(context())->key())->n();
|
||||
}
|
||||
|
||||
QBigInteger RSAPrivateKey::e() const
|
||||
BigInteger RSAPrivateKey::e() const
|
||||
{
|
||||
return static_cast<const RSAContext *>(static_cast<const PKeyContext *>(context())->key())->e();
|
||||
}
|
||||
|
||||
QBigInteger RSAPrivateKey::p() const
|
||||
BigInteger RSAPrivateKey::p() const
|
||||
{
|
||||
return static_cast<const RSAContext *>(static_cast<const PKeyContext *>(context())->key())->p();
|
||||
}
|
||||
|
||||
QBigInteger RSAPrivateKey::q() const
|
||||
BigInteger RSAPrivateKey::q() const
|
||||
{
|
||||
return static_cast<const RSAContext *>(static_cast<const PKeyContext *>(context())->key())->q();
|
||||
}
|
||||
|
||||
QBigInteger RSAPrivateKey::d() const
|
||||
BigInteger RSAPrivateKey::d() const
|
||||
{
|
||||
return static_cast<const RSAContext *>(static_cast<const PKeyContext *>(context())->key())->d();
|
||||
}
|
||||
@ -1310,7 +1310,7 @@ DSAPublicKey::DSAPublicKey()
|
||||
{
|
||||
}
|
||||
|
||||
DSAPublicKey::DSAPublicKey(const DLGroup &domain, const QBigInteger &y, const QString &provider)
|
||||
DSAPublicKey::DSAPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider)
|
||||
{
|
||||
DSAContext *k = static_cast<DSAContext *>(getContext("dsa", provider));
|
||||
k->createPublic(domain, y);
|
||||
@ -1329,7 +1329,7 @@ DLGroup DSAPublicKey::domain() const
|
||||
return static_cast<const DSAContext *>(static_cast<const PKeyContext *>(context())->key())->domain();
|
||||
}
|
||||
|
||||
QBigInteger DSAPublicKey::y() const
|
||||
BigInteger DSAPublicKey::y() const
|
||||
{
|
||||
return static_cast<const DSAContext *>(static_cast<const PKeyContext *>(context())->key())->y();
|
||||
}
|
||||
@ -1341,7 +1341,7 @@ DSAPrivateKey::DSAPrivateKey()
|
||||
{
|
||||
}
|
||||
|
||||
DSAPrivateKey::DSAPrivateKey(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x, const QString &provider)
|
||||
DSAPrivateKey::DSAPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider)
|
||||
{
|
||||
DSAContext *k = static_cast<DSAContext *>(getContext("dsa", provider));
|
||||
k->createPrivate(domain, y, x);
|
||||
@ -1355,12 +1355,12 @@ DLGroup DSAPrivateKey::domain() const
|
||||
return static_cast<const DSAContext *>(static_cast<const PKeyContext *>(context())->key())->domain();
|
||||
}
|
||||
|
||||
QBigInteger DSAPrivateKey::y() const
|
||||
BigInteger DSAPrivateKey::y() const
|
||||
{
|
||||
return static_cast<const DSAContext *>(static_cast<const PKeyContext *>(context())->key())->y();
|
||||
}
|
||||
|
||||
QBigInteger DSAPrivateKey::x() const
|
||||
BigInteger DSAPrivateKey::x() const
|
||||
{
|
||||
return static_cast<const DSAContext *>(static_cast<const PKeyContext *>(context())->key())->x();
|
||||
}
|
||||
@ -1372,7 +1372,7 @@ DHPublicKey::DHPublicKey()
|
||||
{
|
||||
}
|
||||
|
||||
DHPublicKey::DHPublicKey(const DLGroup &domain, const QBigInteger &y, const QString &provider)
|
||||
DHPublicKey::DHPublicKey(const DLGroup &domain, const BigInteger &y, const QString &provider)
|
||||
{
|
||||
DHContext *k = static_cast<DHContext *>(getContext("dh", provider));
|
||||
k->createPublic(domain, y);
|
||||
@ -1391,7 +1391,7 @@ DLGroup DHPublicKey::domain() const
|
||||
return static_cast<const DHContext *>(static_cast<const PKeyContext *>(context())->key())->domain();
|
||||
}
|
||||
|
||||
QBigInteger DHPublicKey::y() const
|
||||
BigInteger DHPublicKey::y() const
|
||||
{
|
||||
return static_cast<const DHContext *>(static_cast<const PKeyContext *>(context())->key())->y();
|
||||
}
|
||||
@ -1403,7 +1403,7 @@ DHPrivateKey::DHPrivateKey()
|
||||
{
|
||||
}
|
||||
|
||||
DHPrivateKey::DHPrivateKey(const DLGroup &domain, const QBigInteger &y, const QBigInteger &x, const QString &provider)
|
||||
DHPrivateKey::DHPrivateKey(const DLGroup &domain, const BigInteger &y, const BigInteger &x, const QString &provider)
|
||||
{
|
||||
DHContext *k = static_cast<DHContext *>(getContext("dh", provider));
|
||||
k->createPrivate(domain, y, x);
|
||||
@ -1417,12 +1417,12 @@ DLGroup DHPrivateKey::domain() const
|
||||
return static_cast<const DHContext *>(static_cast<const PKeyContext *>(context())->key())->domain();
|
||||
}
|
||||
|
||||
QBigInteger DHPrivateKey::y() const
|
||||
BigInteger DHPrivateKey::y() const
|
||||
{
|
||||
return static_cast<const DHContext *>(static_cast<const PKeyContext *>(context())->key())->y();
|
||||
}
|
||||
|
||||
QBigInteger DHPrivateKey::x() const
|
||||
BigInteger DHPrivateKey::x() const
|
||||
{
|
||||
return static_cast<const DHContext *>(static_cast<const PKeyContext *>(context())->key())->x();
|
||||
}
|
||||
|
@ -991,7 +991,7 @@ void SASL::setAuthzid(const QString &authzid)
|
||||
d->c->setClientParams(0, &authzid, 0, 0);
|
||||
}
|
||||
|
||||
void SASL::setPassword(const QSecureArray &pass)
|
||||
void SASL::setPassword(const SecureArray &pass)
|
||||
{
|
||||
d->c->setClientParams(0, 0, &pass, 0);
|
||||
}
|
||||
|
@ -37,27 +37,27 @@ void TextFilter::setup(Direction dir)
|
||||
_dir = dir;
|
||||
}
|
||||
|
||||
QSecureArray TextFilter::encode(const QSecureArray &a)
|
||||
SecureArray TextFilter::encode(const SecureArray &a)
|
||||
{
|
||||
setup(Encode);
|
||||
return process(a);
|
||||
}
|
||||
|
||||
QSecureArray TextFilter::decode(const QSecureArray &a)
|
||||
SecureArray TextFilter::decode(const SecureArray &a)
|
||||
{
|
||||
setup(Decode);
|
||||
return process(a);
|
||||
}
|
||||
|
||||
QString TextFilter::arrayToString(const QSecureArray &a)
|
||||
QString TextFilter::arrayToString(const SecureArray &a)
|
||||
{
|
||||
return QString::fromLatin1(encode(a).toByteArray());
|
||||
}
|
||||
|
||||
QSecureArray TextFilter::stringToArray(const QString &s)
|
||||
SecureArray TextFilter::stringToArray(const QString &s)
|
||||
{
|
||||
if(s.isEmpty())
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
return decode(s.toLatin1());
|
||||
}
|
||||
|
||||
@ -108,11 +108,11 @@ void Hex::clear()
|
||||
_ok = true;
|
||||
}
|
||||
|
||||
QSecureArray Hex::update(const QSecureArray &a)
|
||||
SecureArray Hex::update(const SecureArray &a)
|
||||
{
|
||||
if(_dir == Encode)
|
||||
{
|
||||
QSecureArray out(a.size() * 2);
|
||||
SecureArray out(a.size() * 2);
|
||||
int at = 0;
|
||||
int c;
|
||||
for(int n = 0; n < (int)a.size(); ++n)
|
||||
@ -135,7 +135,7 @@ QSecureArray Hex::update(const QSecureArray &a)
|
||||
out[at++] = (char)c;
|
||||
}
|
||||
if(!_ok)
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
|
||||
return out;
|
||||
}
|
||||
@ -150,7 +150,7 @@ QSecureArray Hex::update(const QSecureArray &a)
|
||||
flag = true;
|
||||
}
|
||||
|
||||
QSecureArray out(a.size() / 2);
|
||||
SecureArray out(a.size() / 2);
|
||||
int at = 0;
|
||||
int c;
|
||||
for(int n = 0; n < (int)a.size(); ++n)
|
||||
@ -175,7 +175,7 @@ QSecureArray Hex::update(const QSecureArray &a)
|
||||
}
|
||||
}
|
||||
if(!_ok)
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
|
||||
if(flag)
|
||||
{
|
||||
@ -186,11 +186,11 @@ QSecureArray Hex::update(const QSecureArray &a)
|
||||
}
|
||||
}
|
||||
|
||||
QSecureArray Hex::final()
|
||||
SecureArray Hex::final()
|
||||
{
|
||||
if(partial)
|
||||
_ok = false;
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
}
|
||||
|
||||
bool Hex::ok() const
|
||||
@ -228,7 +228,7 @@ void Base64::setLineBreaksColumn(int column)
|
||||
_lb_column = 76;
|
||||
}
|
||||
|
||||
static QSecureArray b64encode(const QSecureArray &s)
|
||||
static SecureArray b64encode(const SecureArray &s)
|
||||
{
|
||||
int i;
|
||||
int len = s.size();
|
||||
@ -244,7 +244,7 @@ static QSecureArray b64encode(const QSecureArray &s)
|
||||
"=";
|
||||
int a, b, c;
|
||||
|
||||
QSecureArray p((len + 2) / 3 * 4);
|
||||
SecureArray p((len + 2) / 3 * 4);
|
||||
int at = 0;
|
||||
for(i = 0; i < len; i += 3)
|
||||
{
|
||||
@ -272,7 +272,7 @@ static QSecureArray b64encode(const QSecureArray &s)
|
||||
return p;
|
||||
}
|
||||
|
||||
static QSecureArray b64decode(const QSecureArray &s, bool *ok)
|
||||
static SecureArray b64decode(const SecureArray &s, bool *ok)
|
||||
{
|
||||
// -1 specifies invalid
|
||||
// 64 specifies eof
|
||||
@ -299,7 +299,7 @@ static QSecureArray b64decode(const QSecureArray &s, bool *ok)
|
||||
};
|
||||
|
||||
// return value
|
||||
QSecureArray p;
|
||||
SecureArray p;
|
||||
*ok = true;
|
||||
|
||||
// this should be a multiple of 4
|
||||
@ -343,7 +343,7 @@ static QSecureArray b64decode(const QSecureArray &s, bool *ok)
|
||||
return p;
|
||||
}
|
||||
|
||||
static int findLF(const QSecureArray &in, int offset)
|
||||
static int findLF(const SecureArray &in, int offset)
|
||||
{
|
||||
for(int n = offset; n < in.size(); ++n)
|
||||
{
|
||||
@ -353,9 +353,9 @@ static int findLF(const QSecureArray &in, int offset)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static QSecureArray insert_linebreaks(const QSecureArray &s, int *col, int lfAt)
|
||||
static SecureArray insert_linebreaks(const SecureArray &s, int *col, int lfAt)
|
||||
{
|
||||
QSecureArray out = s;
|
||||
SecureArray out = s;
|
||||
|
||||
int needed = (out.size() + *col) / lfAt; // how many newlines needed?
|
||||
if(needed > 0)
|
||||
@ -391,9 +391,9 @@ static QSecureArray insert_linebreaks(const QSecureArray &s, int *col, int lfAt)
|
||||
return out;
|
||||
}
|
||||
|
||||
static QSecureArray remove_linebreaks(const QSecureArray &s)
|
||||
static SecureArray remove_linebreaks(const SecureArray &s)
|
||||
{
|
||||
QSecureArray out = s;
|
||||
SecureArray out = s;
|
||||
|
||||
int removed = 0;
|
||||
int at = findLF(out, 0);
|
||||
@ -419,23 +419,23 @@ static QSecureArray remove_linebreaks(const QSecureArray &s)
|
||||
return out;
|
||||
}
|
||||
|
||||
static void appendArray(QSecureArray *a, const QSecureArray &b)
|
||||
static void appendArray(SecureArray *a, const SecureArray &b)
|
||||
{
|
||||
int oldsize = a->size();
|
||||
a->resize(oldsize + b.size());
|
||||
memcpy(a->data() + oldsize, b.data(), b.size());
|
||||
}
|
||||
|
||||
QSecureArray Base64::update(const QSecureArray &a)
|
||||
SecureArray Base64::update(const SecureArray &a)
|
||||
{
|
||||
QSecureArray in;
|
||||
SecureArray in;
|
||||
if(_dir == Decode && _lb_enabled)
|
||||
in = remove_linebreaks(a);
|
||||
else
|
||||
in = a;
|
||||
|
||||
if(in.isEmpty())
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
|
||||
int chunk;
|
||||
if(_dir == Encode)
|
||||
@ -447,13 +447,13 @@ QSecureArray Base64::update(const QSecureArray &a)
|
||||
if(size < chunk)
|
||||
{
|
||||
appendArray(&partial, in);
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
}
|
||||
|
||||
int eat = size % chunk;
|
||||
|
||||
// s = partial + a - eat
|
||||
QSecureArray s(partial.size() + in.size() - eat);
|
||||
SecureArray s(partial.size() + in.size() - eat);
|
||||
memcpy(s.data(), partial.data(), partial.size());
|
||||
memcpy(s.data() + partial.size(), in.data(), in.size() - eat);
|
||||
|
||||
@ -470,14 +470,14 @@ QSecureArray Base64::update(const QSecureArray &a)
|
||||
else
|
||||
{
|
||||
bool ok;
|
||||
QSecureArray out = b64decode(s, &ok);
|
||||
SecureArray out = b64decode(s, &ok);
|
||||
if(!ok)
|
||||
_ok = false;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
QSecureArray Base64::final()
|
||||
SecureArray Base64::final()
|
||||
{
|
||||
if(_dir == Encode)
|
||||
{
|
||||
@ -489,7 +489,7 @@ QSecureArray Base64::final()
|
||||
else
|
||||
{
|
||||
bool ok;
|
||||
QSecureArray out = b64decode(partial, &ok);
|
||||
SecureArray out = b64decode(partial, &ok);
|
||||
if(!ok)
|
||||
_ok = false;
|
||||
return out;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2003-2005 Justin Karneges <justin@affinix.com>
|
||||
* Copyright (C) 2003-2007 Justin Karneges <justin@affinix.com>
|
||||
* Copyright (C) 2004,2005 Brad Hards <bradh@frogmouth.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
@ -151,12 +151,12 @@ void *qca_secure_realloc(void *p, int bytes)
|
||||
return new_p;
|
||||
}
|
||||
|
||||
using namespace QCA;
|
||||
namespace QCA {
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// QSecureArray
|
||||
// SecureArray
|
||||
//----------------------------------------------------------------------------
|
||||
class QSecureArray::Private : public QSharedData
|
||||
class SecureArray::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Botan::SecureVector<Botan::byte> *buf;
|
||||
@ -203,12 +203,12 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
QSecureArray::QSecureArray()
|
||||
SecureArray::SecureArray()
|
||||
{
|
||||
d = 0;
|
||||
}
|
||||
|
||||
QSecureArray::QSecureArray(int size, char ch)
|
||||
SecureArray::SecureArray(int size, char ch)
|
||||
{
|
||||
if(size > 0)
|
||||
{
|
||||
@ -222,7 +222,7 @@ QSecureArray::QSecureArray(int size, char ch)
|
||||
d = 0;
|
||||
}
|
||||
|
||||
QSecureArray::QSecureArray(const char *str)
|
||||
SecureArray::SecureArray(const char *str)
|
||||
{
|
||||
QByteArray a = QByteArray::fromRawData(str, strlen(str));
|
||||
if(a.size() > 0)
|
||||
@ -231,29 +231,29 @@ QSecureArray::QSecureArray(const char *str)
|
||||
d = 0;
|
||||
}
|
||||
|
||||
QSecureArray::QSecureArray(const QByteArray &a)
|
||||
SecureArray::SecureArray(const QByteArray &a)
|
||||
{
|
||||
d = 0;
|
||||
*this = a;
|
||||
}
|
||||
|
||||
QSecureArray::QSecureArray(const QSecureArray &from)
|
||||
SecureArray::SecureArray(const SecureArray &from)
|
||||
{
|
||||
d = 0;
|
||||
*this = from;
|
||||
}
|
||||
|
||||
QSecureArray::~QSecureArray()
|
||||
SecureArray::~SecureArray()
|
||||
{
|
||||
}
|
||||
|
||||
QSecureArray & QSecureArray::operator=(const QSecureArray &from)
|
||||
SecureArray & SecureArray::operator=(const SecureArray &from)
|
||||
{
|
||||
d = from.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QSecureArray & QSecureArray::operator=(const QByteArray &from)
|
||||
SecureArray & SecureArray::operator=(const QByteArray &from)
|
||||
{
|
||||
d = 0;
|
||||
if(!from.isEmpty())
|
||||
@ -262,12 +262,12 @@ QSecureArray & QSecureArray::operator=(const QByteArray &from)
|
||||
return *this;
|
||||
}
|
||||
|
||||
void QSecureArray::clear()
|
||||
void SecureArray::clear()
|
||||
{
|
||||
d = 0;
|
||||
}
|
||||
|
||||
bool QSecureArray::resize(int size)
|
||||
bool SecureArray::resize(int size)
|
||||
{
|
||||
int cur_size = (d ? d->size : 0);
|
||||
if(cur_size == size)
|
||||
@ -290,31 +290,31 @@ bool QSecureArray::resize(int size)
|
||||
return true;
|
||||
}
|
||||
|
||||
char & QSecureArray::operator[](int index)
|
||||
char & SecureArray::operator[](int index)
|
||||
{
|
||||
return at(index);
|
||||
}
|
||||
|
||||
const char & QSecureArray::operator[](int index) const
|
||||
const char & SecureArray::operator[](int index) const
|
||||
{
|
||||
return at(index);
|
||||
}
|
||||
|
||||
char & QSecureArray::at(int index)
|
||||
char & SecureArray::at(int index)
|
||||
{
|
||||
Botan::byte *bp = (Botan::byte *)(*d->buf) + index;
|
||||
char *cp = (char *)bp;
|
||||
return *cp;
|
||||
}
|
||||
|
||||
const char & QSecureArray::at(int index) const
|
||||
const char & SecureArray::at(int index) const
|
||||
{
|
||||
const Botan::byte *bp = (const Botan::byte *)(*d->buf) + index;
|
||||
const char *cp = (const char *)bp;
|
||||
return *cp;
|
||||
}
|
||||
|
||||
char *QSecureArray::data()
|
||||
char *SecureArray::data()
|
||||
{
|
||||
if(!d)
|
||||
return 0;
|
||||
@ -322,7 +322,7 @@ char *QSecureArray::data()
|
||||
return ((char *)p);
|
||||
}
|
||||
|
||||
const char *QSecureArray::data() const
|
||||
const char *SecureArray::data() const
|
||||
{
|
||||
if(!d)
|
||||
return 0;
|
||||
@ -330,22 +330,22 @@ const char *QSecureArray::data() const
|
||||
return ((const char *)p);
|
||||
}
|
||||
|
||||
const char *QSecureArray::constData() const
|
||||
const char *SecureArray::constData() const
|
||||
{
|
||||
return data();
|
||||
}
|
||||
|
||||
int QSecureArray::size() const
|
||||
int SecureArray::size() const
|
||||
{
|
||||
return (d ? d->size : 0);
|
||||
}
|
||||
|
||||
bool QSecureArray::isEmpty() const
|
||||
bool SecureArray::isEmpty() const
|
||||
{
|
||||
return (size() == 0);
|
||||
}
|
||||
|
||||
QByteArray QSecureArray::toByteArray() const
|
||||
QByteArray SecureArray::toByteArray() const
|
||||
{
|
||||
if(isEmpty())
|
||||
return QByteArray();
|
||||
@ -355,7 +355,7 @@ QByteArray QSecureArray::toByteArray() const
|
||||
return buf;
|
||||
}
|
||||
|
||||
QSecureArray & QSecureArray::append(const QSecureArray &a)
|
||||
SecureArray & SecureArray::append(const SecureArray &a)
|
||||
{
|
||||
int oldsize = size();
|
||||
resize(oldsize + a.size());
|
||||
@ -363,29 +363,29 @@ QSecureArray & QSecureArray::append(const QSecureArray &a)
|
||||
return *this;
|
||||
}
|
||||
|
||||
QSecureArray & QSecureArray::operator+=(const QSecureArray &a)
|
||||
SecureArray & SecureArray::operator+=(const SecureArray &a)
|
||||
{
|
||||
return append(a);
|
||||
}
|
||||
|
||||
void QSecureArray::fill(char fillChar, int fillToPosition)
|
||||
void SecureArray::fill(char fillChar, int fillToPosition)
|
||||
{
|
||||
int len = (fillToPosition == -1) ? size() : qMin(fillToPosition, size());
|
||||
if(len > 0)
|
||||
memset(data(), (int)fillChar, len);
|
||||
}
|
||||
|
||||
void QSecureArray::set(const QSecureArray &from)
|
||||
void SecureArray::set(const SecureArray &from)
|
||||
{
|
||||
*this = from;
|
||||
}
|
||||
|
||||
void QSecureArray::set(const QByteArray &from)
|
||||
void SecureArray::set(const QByteArray &from)
|
||||
{
|
||||
*this = from;
|
||||
}
|
||||
|
||||
bool operator==(const QSecureArray &a, const QSecureArray &b)
|
||||
bool operator==(const SecureArray &a, const SecureArray &b)
|
||||
{
|
||||
if(&a == &b)
|
||||
return true;
|
||||
@ -394,19 +394,19 @@ bool operator==(const QSecureArray &a, const QSecureArray &b)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator!=(const QSecureArray &a, const QSecureArray &b)
|
||||
bool operator!=(const SecureArray &a, const SecureArray &b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
const QSecureArray operator+(const QSecureArray &a, const QSecureArray &b)
|
||||
const SecureArray operator+(const SecureArray &a, const SecureArray &b)
|
||||
{
|
||||
QSecureArray c = a;
|
||||
SecureArray c = a;
|
||||
return c.append(b);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// QBigInteger
|
||||
// BigInteger
|
||||
//----------------------------------------------------------------------------
|
||||
static void negate_binary(char *a, int size)
|
||||
{
|
||||
@ -428,18 +428,18 @@ static void negate_binary(char *a, int size)
|
||||
}
|
||||
}
|
||||
|
||||
class QBigInteger::Private : public QSharedData
|
||||
class BigInteger::Private : public QSharedData
|
||||
{
|
||||
public:
|
||||
Botan::BigInt n;
|
||||
};
|
||||
|
||||
QBigInteger::QBigInteger()
|
||||
BigInteger::BigInteger()
|
||||
{
|
||||
d = new Private;
|
||||
}
|
||||
|
||||
QBigInteger::QBigInteger(int i)
|
||||
BigInteger::BigInteger(int i)
|
||||
{
|
||||
d = new Private;
|
||||
if(i < 0)
|
||||
@ -454,82 +454,82 @@ QBigInteger::QBigInteger(int i)
|
||||
}
|
||||
}
|
||||
|
||||
QBigInteger::QBigInteger(const char *c)
|
||||
BigInteger::BigInteger(const char *c)
|
||||
{
|
||||
d = new Private;
|
||||
fromString(QString(c));
|
||||
}
|
||||
|
||||
QBigInteger::QBigInteger(const QString &s)
|
||||
BigInteger::BigInteger(const QString &s)
|
||||
{
|
||||
d = new Private;
|
||||
fromString(s);
|
||||
}
|
||||
|
||||
QBigInteger::QBigInteger(const QSecureArray &a)
|
||||
BigInteger::BigInteger(const SecureArray &a)
|
||||
{
|
||||
d = new Private;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
QBigInteger::QBigInteger(const QBigInteger &from)
|
||||
BigInteger::BigInteger(const BigInteger &from)
|
||||
{
|
||||
*this = from;
|
||||
}
|
||||
|
||||
QBigInteger::~QBigInteger()
|
||||
BigInteger::~BigInteger()
|
||||
{
|
||||
}
|
||||
|
||||
QBigInteger & QBigInteger::operator=(const QBigInteger &from)
|
||||
BigInteger & BigInteger::operator=(const BigInteger &from)
|
||||
{
|
||||
d = from.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QBigInteger & QBigInteger::operator+=(const QBigInteger &i)
|
||||
BigInteger & BigInteger::operator+=(const BigInteger &i)
|
||||
{
|
||||
d->n += i.d->n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QBigInteger & QBigInteger::operator-=(const QBigInteger &i)
|
||||
BigInteger & BigInteger::operator-=(const BigInteger &i)
|
||||
{
|
||||
d->n -= i.d->n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
QBigInteger & QBigInteger::operator=(const QString &s)
|
||||
BigInteger & BigInteger::operator=(const QString &s)
|
||||
{
|
||||
fromString(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
int QBigInteger::compare(const QBigInteger &n) const
|
||||
int BigInteger::compare(const BigInteger &n) const
|
||||
{
|
||||
return ( (d->n).cmp( n.d->n, true) );
|
||||
}
|
||||
|
||||
QTextStream &operator<<(QTextStream &stream, const QBigInteger& b)
|
||||
QTextStream &operator<<(QTextStream &stream, const BigInteger& b)
|
||||
{
|
||||
stream << b.toString();
|
||||
return stream;
|
||||
}
|
||||
|
||||
QSecureArray QBigInteger::toArray() const
|
||||
SecureArray BigInteger::toArray() const
|
||||
{
|
||||
int size = d->n.encoded_size(Botan::BigInt::Binary);
|
||||
|
||||
// return at least 8 bits
|
||||
if(size == 0)
|
||||
{
|
||||
QSecureArray a(1);
|
||||
SecureArray a(1);
|
||||
a[0] = 0;
|
||||
return a;
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
QSecureArray a;
|
||||
SecureArray a;
|
||||
|
||||
// make room for a sign bit if needed
|
||||
if(d->n.get_bit((size * 8) - 1))
|
||||
@ -550,14 +550,14 @@ QSecureArray QBigInteger::toArray() const
|
||||
return a;
|
||||
}
|
||||
|
||||
void QBigInteger::fromArray(const QSecureArray &_a)
|
||||
void BigInteger::fromArray(const SecureArray &_a)
|
||||
{
|
||||
if(_a.isEmpty())
|
||||
{
|
||||
d->n = Botan::BigInt(0);
|
||||
return;
|
||||
}
|
||||
QSecureArray a = _a;
|
||||
SecureArray a = _a;
|
||||
|
||||
Botan::BigInt::Sign sign = Botan::BigInt::Positive;
|
||||
if(a[0] & 0x80)
|
||||
@ -570,7 +570,7 @@ void QBigInteger::fromArray(const QSecureArray &_a)
|
||||
d->n.set_sign(sign);
|
||||
}
|
||||
|
||||
QString QBigInteger::toString() const
|
||||
QString BigInteger::toString() const
|
||||
{
|
||||
QByteArray cs;
|
||||
try
|
||||
@ -590,7 +590,7 @@ QString QBigInteger::toString() const
|
||||
return str;
|
||||
}
|
||||
|
||||
bool QBigInteger::fromString(const QString &s)
|
||||
bool BigInteger::fromString(const QString &s)
|
||||
{
|
||||
if(s.isEmpty())
|
||||
return false;
|
||||
@ -615,3 +615,5 @@ bool QBigInteger::fromString(const QString &s)
|
||||
d->n.set_sign(Botan::BigInt::Positive);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -120,12 +120,12 @@ public slots:
|
||||
out.write(a);
|
||||
}
|
||||
|
||||
QSecureArray readSecure(int bytes = -1)
|
||||
QCA::SecureArray readSecure(int bytes = -1)
|
||||
{
|
||||
return in.readSecure(bytes);
|
||||
}
|
||||
|
||||
void writeSecure(const QSecureArray &a)
|
||||
void writeSecure(const QCA::SecureArray &a)
|
||||
{
|
||||
out.writeSecure(a);
|
||||
}
|
||||
@ -206,7 +206,7 @@ public:
|
||||
|
||||
ConsoleThread(QObject *parent = 0) : SyncThread(parent)
|
||||
{
|
||||
qRegisterMetaType<QSecureArray>("QSecureArray");
|
||||
qRegisterMetaType<SecureArray>("QCA::SecureArray");
|
||||
}
|
||||
|
||||
~ConsoleThread()
|
||||
@ -255,14 +255,14 @@ public:
|
||||
mycall(worker, "write", QVariantList() << a);
|
||||
}
|
||||
|
||||
QSecureArray readSecure(int bytes = -1)
|
||||
SecureArray readSecure(int bytes = -1)
|
||||
{
|
||||
return qVariantValue<QSecureArray>(mycall(worker, "readSecure", QVariantList() << bytes));
|
||||
return qVariantValue<SecureArray>(mycall(worker, "readSecure", QVariantList() << bytes));
|
||||
}
|
||||
|
||||
void writeSecure(const QSecureArray &a)
|
||||
void writeSecure(const SecureArray &a)
|
||||
{
|
||||
mycall(worker, "writeSecure", QVariantList() << qVariantFromValue<QSecureArray>(a));
|
||||
mycall(worker, "writeSecure", QVariantList() << qVariantFromValue<SecureArray>(a));
|
||||
}
|
||||
|
||||
void closeOutput()
|
||||
@ -659,12 +659,12 @@ void ConsoleReference::write(const QByteArray &a)
|
||||
d->thread->write(a);
|
||||
}
|
||||
|
||||
QSecureArray ConsoleReference::readSecure(int bytes)
|
||||
SecureArray ConsoleReference::readSecure(int bytes)
|
||||
{
|
||||
return d->thread->readSecure(bytes);
|
||||
}
|
||||
|
||||
void ConsoleReference::writeSecure(const QSecureArray &a)
|
||||
void ConsoleReference::writeSecure(const SecureArray &a)
|
||||
{
|
||||
d->thread->writeSecure(a);
|
||||
}
|
||||
@ -694,7 +694,7 @@ public:
|
||||
Synchronizer sync;
|
||||
ConsoleReference console;
|
||||
QString promptStr;
|
||||
QSecureArray result;
|
||||
SecureArray result;
|
||||
int at;
|
||||
bool done;
|
||||
bool enterMode;
|
||||
@ -818,7 +818,7 @@ private slots:
|
||||
{
|
||||
while(console.bytesAvailable() > 0)
|
||||
{
|
||||
QSecureArray buf = console.readSecure(1);
|
||||
SecureArray buf = console.readSecure(1);
|
||||
if(buf.isEmpty())
|
||||
break;
|
||||
|
||||
@ -861,17 +861,17 @@ ConsolePrompt::~ConsolePrompt()
|
||||
delete d;
|
||||
}
|
||||
|
||||
QSecureArray ConsolePrompt::getHidden(const QString &promptStr)
|
||||
SecureArray ConsolePrompt::getHidden(const QString &promptStr)
|
||||
{
|
||||
ConsolePrompt p;
|
||||
p.d->promptStr = promptStr;
|
||||
if(!p.d->start(false))
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
|
||||
// convert result from utf16 to utf8, securely
|
||||
QTextCodec *codec = QTextCodec::codecForMib(106);
|
||||
QTextCodec::ConverterState cstate(QTextCodec::IgnoreHeader);
|
||||
QSecureArray out;
|
||||
SecureArray out;
|
||||
ushort *ustr = (ushort *)p.d->result.data();
|
||||
int len = p.d->result.size() / sizeof(ushort);
|
||||
for(int n = 0; n < len; ++n)
|
||||
|
@ -1240,7 +1240,7 @@ int QPipeDevice::read(char *data, int maxsize)
|
||||
int num = size / CONSOLE_CHAREXPAND;
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
QSecureArray destbuf(num * sizeof(ushort), 0);
|
||||
SecureArray destbuf(num * sizeof(ushort), 0);
|
||||
#else
|
||||
QByteArray destbuf(num * sizeof(ushort), 0);
|
||||
#endif
|
||||
@ -1436,8 +1436,8 @@ public:
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
bool secure;
|
||||
QSecureArray sec_buf;
|
||||
QSecureArray sec_curWrite;
|
||||
SecureArray sec_buf;
|
||||
SecureArray sec_curWrite;
|
||||
#endif
|
||||
QTimer readTrigger, writeTrigger, closeTrigger, writeErrorTrigger;
|
||||
bool canRead, activeWrite;
|
||||
@ -1521,7 +1521,7 @@ public:
|
||||
}
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
void appendArray(QSecureArray *a, const QSecureArray &b)
|
||||
void appendArray(SecureArray *a, const SecureArray &b)
|
||||
{
|
||||
a->append(b);
|
||||
}
|
||||
@ -1536,7 +1536,7 @@ public:
|
||||
}
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
void takeArray(QSecureArray *a, int len)
|
||||
void takeArray(SecureArray *a, int len)
|
||||
{
|
||||
char *p = a->data();
|
||||
int newsize = a->size() - len;
|
||||
@ -1588,9 +1588,9 @@ public:
|
||||
}
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
QSecureArray readSecure(QSecureArray *buf, int bytes)
|
||||
SecureArray readSecure(SecureArray *buf, int bytes)
|
||||
{
|
||||
QSecureArray a;
|
||||
SecureArray a;
|
||||
if(bytes == -1 || bytes > buf->size())
|
||||
{
|
||||
a = *buf;
|
||||
@ -1606,7 +1606,7 @@ public:
|
||||
return a;
|
||||
}
|
||||
|
||||
void writeSecure(QSecureArray *buf, const QSecureArray &a)
|
||||
void writeSecure(SecureArray *buf, const SecureArray &a)
|
||||
{
|
||||
appendArray(buf, a);
|
||||
setupNextWrite();
|
||||
@ -1716,7 +1716,7 @@ public slots:
|
||||
#ifdef QPIPE_SECURE
|
||||
if(secure)
|
||||
{
|
||||
QSecureArray a(max);
|
||||
SecureArray a(max);
|
||||
ret = pipe.read(a.data(), a.size());
|
||||
if(ret >= 1)
|
||||
{
|
||||
@ -1947,12 +1947,12 @@ void QPipeEnd::write(const QByteArray &buf)
|
||||
}
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
QSecureArray QPipeEnd::readSecure(int bytes)
|
||||
SecureArray QPipeEnd::readSecure(int bytes)
|
||||
{
|
||||
return d->readSecure(&d->sec_buf, bytes);
|
||||
}
|
||||
|
||||
void QPipeEnd::writeSecure(const QSecureArray &buf)
|
||||
void QPipeEnd::writeSecure(const SecureArray &buf)
|
||||
{
|
||||
if(!isValid() || d->closing)
|
||||
return;
|
||||
@ -1979,13 +1979,13 @@ QByteArray QPipeEnd::takeBytesToWrite()
|
||||
}
|
||||
|
||||
#ifdef QPIPE_SECURE
|
||||
QSecureArray QPipeEnd::takeBytesToWriteSecure()
|
||||
SecureArray QPipeEnd::takeBytesToWriteSecure()
|
||||
{
|
||||
// only call this on inactive sessions
|
||||
if(isValid())
|
||||
return QSecureArray();
|
||||
return SecureArray();
|
||||
|
||||
QSecureArray a = d->sec_buf;
|
||||
SecureArray a = d->sec_buf;
|
||||
d->sec_buf.clear();
|
||||
return a;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ public:
|
||||
bool warned;
|
||||
bool have_pass;
|
||||
bool used_pass;
|
||||
QSecureArray pass;
|
||||
QCA::SecureArray pass;
|
||||
|
||||
PassphrasePrompt()
|
||||
{
|
||||
@ -178,7 +178,7 @@ public:
|
||||
handler.start();
|
||||
}
|
||||
|
||||
void setExplicitPassword(const QSecureArray &_pass)
|
||||
void setExplicitPassword(const QCA::SecureArray &_pass)
|
||||
{
|
||||
have_pass = true;
|
||||
used_pass = false;
|
||||
@ -252,7 +252,7 @@ private slots:
|
||||
else
|
||||
str = QString("Enter %1").arg(type);
|
||||
|
||||
QSecureArray result = QCA::ConsolePrompt::getHidden(str);
|
||||
QCA::SecureArray result = QCA::ConsolePrompt::getHidden(str);
|
||||
handler.submitPassword(id, result);
|
||||
}
|
||||
else if(e.type() == QCA::Event::Token)
|
||||
@ -310,9 +310,9 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
static bool promptForNewPassphrase(QSecureArray *result)
|
||||
static bool promptForNewPassphrase(QCA::SecureArray *result)
|
||||
{
|
||||
QSecureArray out = QCA::ConsolePrompt::getHidden("Enter new passphrase");
|
||||
QCA::SecureArray out = QCA::ConsolePrompt::getHidden("Enter new passphrase");
|
||||
if(QCA::ConsolePrompt::getHidden("Confirm new passphrase") != out)
|
||||
{
|
||||
fprintf(stderr, "Error: confirmation does not match original entry.\n");
|
||||
@ -639,7 +639,7 @@ static QCA::CertificateOptions promptForCertAttributes(bool advanced, bool req)
|
||||
while(1)
|
||||
{
|
||||
QString str = prompt_for("Serial Number");
|
||||
QBigInteger num;
|
||||
QCA::BigInteger num;
|
||||
if(str.isEmpty() || !num.fromString(str))
|
||||
{
|
||||
printf("'%s' is not a valid entry.\n", qPrintable(str));
|
||||
@ -1448,7 +1448,7 @@ static QCA::KeyStoreEntry get_E(const QString &name, bool nopassiveerror = false
|
||||
return entry;
|
||||
}
|
||||
|
||||
static QCA::PrivateKey get_K(const QString &name, const QSecureArray &pass)
|
||||
static QCA::PrivateKey get_K(const QString &name, const QCA::SecureArray &pass)
|
||||
{
|
||||
QCA::PrivateKey key;
|
||||
|
||||
@ -1517,7 +1517,7 @@ static QCA::KeyBundle get_X(const QString &name)
|
||||
|
||||
// try file
|
||||
// TODO: remove passphrase arg after api update
|
||||
QCA::KeyBundle key = QCA::KeyBundle::fromFile(name, QSecureArray());
|
||||
QCA::KeyBundle key = QCA::KeyBundle::fromFile(name, QCA::SecureArray());
|
||||
if(key.isNull())
|
||||
{
|
||||
printf("Error: unable to read/process keybundle file.\n");
|
||||
@ -1631,7 +1631,7 @@ int main(int argc, char **argv)
|
||||
|
||||
bool have_pass = false;
|
||||
bool have_newpass = false;
|
||||
QSecureArray pass, newpass;
|
||||
QCA::SecureArray pass, newpass;
|
||||
bool allowprompt = true;
|
||||
bool ordered = false;
|
||||
bool debug = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user