mirror of
https://github.com/chris2511/xca.git
synced 2026-09-12 19:51:05 +05:00
OpenSSL-3: unify hex-ouput: toHexBlock()
print ByteArray as 16 byte colon separated lines
This commit is contained in:
parent
be0d7e3a13
commit
8c72633186
@ -291,3 +291,12 @@ QString appendXcaComment(QString current, QString msg)
|
||||
current += "\n";
|
||||
return current + QString("(%1)\n").arg(msg);
|
||||
}
|
||||
|
||||
QString toHexBlock(const QByteArray &ba)
|
||||
{
|
||||
QByteArray hex;
|
||||
for(int i = 0; i < ba.size(); i += 16)
|
||||
hex += ba.mid(i, 16).toHex(':') + '\n';
|
||||
hex.chop(1);
|
||||
return QString::fromLatin1(hex);
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ void *d2i_bytearray(void *(*d2i)(void*, unsigned char**, long),
|
||||
QString appendXcaComment(QString current, QString msg);
|
||||
|
||||
QString get_ossl_verify_error(int err);
|
||||
QString toHexBlock(const QByteArray &ba);
|
||||
|
||||
/* from version.cpp */
|
||||
const char *version_str(bool html);
|
||||
|
||||
@ -362,19 +362,10 @@ void pki_key::writePublic(XFile &file, bool pem) const
|
||||
file.write(b);
|
||||
}
|
||||
|
||||
QString pki_key::BN2QString(const BIGNUM *bn) const
|
||||
{
|
||||
QByteArray hex, ba = BioByteArray(bn);
|
||||
for(int i = 0; i<ba.size(); i += 16)
|
||||
hex += ba.mid(i, 16).toHex(':') + '\n';
|
||||
hex.chop(1);
|
||||
return QString::fromLatin1(hex);
|
||||
}
|
||||
|
||||
QString pki_key::BignumParamQString(const char *param_name) const
|
||||
{
|
||||
BIGNUM *bn = BignumParam(param_name);
|
||||
QString ret = BN2QString(bn);
|
||||
QString ret = toHexBlock(BioByteArray(bn));
|
||||
if(bn)
|
||||
BN_free(bn);
|
||||
return ret;
|
||||
|
||||
@ -180,7 +180,6 @@ class pki_key: public pki_base
|
||||
int key_size;
|
||||
bool isPub;
|
||||
EVP_PKEY *key;
|
||||
QString BN2QString(const BIGNUM *bn) const;
|
||||
QByteArray SSH2publicQByteArray(bool raw=false) const;
|
||||
QByteArray X509_PUBKEY_public_key() const;
|
||||
QByteArray PEM_comment() const;
|
||||
|
||||
@ -128,7 +128,7 @@ void KeyDetail::setKey(pki_key *key, bool import)
|
||||
MainWindow::getResolver(),
|
||||
SLOT(searchOid(QString)));
|
||||
keyPubEx->setToolTip(CurveComment(nid));
|
||||
keyModulus->setText(key->BignumParamQString(OSSL_PKEY_PARAM_PUB_KEY));
|
||||
keyModulus->setText(toHexBlock(key->QByteArrayParam(OSSL_PKEY_PARAM_PUB_KEY)));
|
||||
break;
|
||||
#ifdef EVP_PKEY_ED25519
|
||||
case EVP_PKEY_ED25519:
|
||||
@ -136,7 +136,7 @@ void KeyDetail::setKey(pki_key *key, bool import)
|
||||
tlPrivEx->setText(tr("Private key"));
|
||||
tlPubEx->setText(tr("Curve name"));
|
||||
keyPubEx->setText("ed25519");
|
||||
keyModulus->setText(key->ed25519PubKey().toHex());
|
||||
keyModulus->setText(toHexBlock(key->ed25519PubKey()));
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user