xca/lib/pki_key.h
Christian Hohnstaedt 4b3ee2c705 Switch database format to SQL(ite)
This is a large squash of many small commits.

Allow porting data from the legacy format to SQL.
Store Binaries base64 encoded and use db->transaction
Update password hash to be 8000 x SHA512 with 8 byte Salt
Add revocations table and fixup CRL generation
Add comment and insertion date columns

Fix column saving, remove trust, add XcaDialog
Allow changing the internal name and comment in Cert/Req details view
Extend Comment functionality, Replace About.ui by XcaDialog.ui
2018-03-05 07:42:36 +01:00

89 lines
2.0 KiB
C++

/*
* Copyright (C) 2001 - 2015 Christian Hohnstaedt.
*
* All rights reserved.
*/
#ifndef __PKI_KEY_H
#define __PKI_KEY_H
#include <QString>
#include <QProgressBar>
#include <openssl/rsa.h>
#include <openssl/bn.h>
#include <openssl/pem.h>
#include <openssl/evp.h>
#include "pki_base.h"
#include "builtin_curves.h"
#define MAX_KEY_LENGTH 4096
class pki_key: public pki_base
{
Q_OBJECT
protected:
int ownPass, key_size;
bool isPub;
EVP_PKEY *key;
QString BN2QString(const BIGNUM *bn) const;
QString BNoneLine(BIGNUM *bn) const;
QByteArray SSH2publicQByteArray();
private:
BIGNUM *ssh_key_data2bn(QByteArray *ba, bool skip = false);
void ssh_key_QBA2data(QByteArray &ba, QByteArray *data);
void ssh_key_bn2data(const BIGNUM *bn, QByteArray *data);
int ucount; // usage counter
public:
pki_key(const QString name = "");
pki_key(const pki_key *pk);
virtual ~pki_key();
const char *getClassName() const;
static builtin_curves builtinCurves;
enum passType { ptCommon, ptPrivate, ptBogus, ptPin };
QString length() const;
QString comboText() const;
virtual EVP_PKEY *decryptKey(int oldkey=0) const;
virtual const EVP_MD *getDefaultMD();
virtual bool isToken();
virtual QString getTypeString(void) const;
virtual QList<int> possibleHashNids();
virtual QString getMsg(msg_type msg);
void writePublic(const QString fname, bool pem);
bool compare(pki_base *ref);
int getKeyType() const;
bool isPrivKey() const;
int getUcount();
int getOwnPass(void)
{
return ownPass;
}
EVP_PKEY *getPubKey()
{
return key;
}
bool isPubKey() const
{
return isPub;
}
BIO *pem(BIO *, int);
QVariant column_data(dbheader *hd);
QString modulus();
QString pubEx();
QString subprime();
QString pubkey();
int ecParamNid();
QString ecPubKey();
void d2i(QByteArray &ba);
void d2i_old(QByteArray &ba, int type);
QByteArray i2d();
EVP_PKEY *load_ssh2_key(FILE *fp);
void writeSSH2public(QString fname);
QSqlError insertSqlData();
QSqlError deleteSqlData();
QSqlError restoreSql(QVariant sqlId);
};
#endif