QOpcUaKeyPair Class
QOpcUaKeyPair は、秘密鍵と公開鍵のペアを扱います。詳細...
| ヘッダー: | #include <QOpcUaKeyPair> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS OpcUa) target_link_libraries(mytarget PRIVATE Qt6::OpcUa) |
| qmake: | QT += opcua |
| 継承元: | QObject |
パブリック型
| enum class | Cipher { Aes128Cbc, Unencrypted } |
| enum class | KeyType { Rsa, Empty, Unknown } |
| enum class | RsaKeyStrength { Bits1024, Bits2048, Bits4096 } |
パブリック関数
| QOpcUaKeyPair(QObject *parent = nullptr) | |
| virtual | ~QOpcUaKeyPair() |
| void | generateRsaKey(QOpcUaKeyPair::RsaKeyStrength strength) |
| bool | hasPrivateKey() const |
| bool | loadFromPemData(const QByteArray &data) |
| QByteArray | privateKeyToByteArray(QOpcUaKeyPair::Cipher cipher, const QString &password) const |
| QByteArray | publicKeyToByteArray() const |
| QOpcUaKeyPair::KeyType | type() const |
シグナル
| void | passphraseNeeded(QString &passphrase, int maximumLength, bool writeOperation) |
詳細な説明
このクラスは現在、テクノロジー プレビューとして提供されているため、このクラスが提供する API および機能は、事前の予告なくいつでも変更される可能性があります。
このクラスは、非対称暗号化用の鍵を生成、読み込み、保存することができます。このクラスのインスタンスは、鍵を必要とする関数に渡す必要があります。
メンバ型のドキュメント
enum class QOpcUaKeyPair::Cipher
秘密鍵の暗号化に用いられる暗号方式。
| 定数 | 値 | 説明 |
|---|---|---|
QOpcUaKeyPair::Cipher::Aes128Cbc | 0 | CBC モードでの AES128 の暗号化 |
QOpcUaKeyPair::Cipher::Unencrypted | 1 | 鍵は暗号化されません。 |
enum class QOpcUaKeyPair::KeyType
この列挙型は、キーの型を指定します。
| 定数 | 定数値 | 説明 |
|---|---|---|
QOpcUaKeyPair::KeyType::Rsa | 0 | RSA キー |
QOpcUaKeyPair::KeyType::Empty | 1 | 利用可能なキーがありません。 |
QOpcUaKeyPair::KeyType::Unknown | 2 | この種類の鍵はサポートされていません。 |
enum class QOpcUaKeyPair::RsaKeyStrength
この列挙型は、RSA鍵の強さを指定します。
| 定数 | 値 | 説明 |
|---|---|---|
QOpcUaKeyPair::RsaKeyStrength::Bits1024 | 1024 | 1024 ビットの鍵強度。 |
QOpcUaKeyPair::RsaKeyStrength::Bits2048 | 2048 | 2048 ビットの鍵強度。 |
QOpcUaKeyPair::RsaKeyStrength::Bits4096 | 4096 | 4096 ビットの鍵強度。 |
メンバー関数のドキュメント
QOpcUaKeyPair::QOpcUaKeyPair(QObject *parent = nullptr)
parent を親オブジェクトとする、新しい空のキーペアを作成します。
[virtual noexcept] QOpcUaKeyPair::~QOpcUaKeyPair()
鍵ペアを削除します。
void QOpcUaKeyPair::generateRsaKey(QOpcUaKeyPair::RsaKeyStrength strength)
新しい非対称RSA鍵ペアを生成します。
鍵の長さは、strength で指定します。
bool QOpcUaKeyPair::hasPrivateKey() const
現在のキーに秘密鍵が含まれている場合は `true ` を返し、そうでない場合は `false` を返します。
bool QOpcUaKeyPair::loadFromPemData(const QByteArray &data)
data 内のPEMエンコードされたデータから鍵を読み込みます。成功した場合はtrue を返し、それ以外の場合はfalse を返します。
データが秘密鍵か公開鍵かを、PEMヘッダーから判別します。暗号化された鍵を読み込むには、パスフレーズを入力するために、passphraseNeeded シグナルに関数を接続します。
[signal] void QOpcUaKeyPair::passphraseNeeded(QString &passphrase, int maximumLength, bool writeOperation)
このシグナルは、秘密鍵が暗号化または復号化のためにpassphrase を必要とする場合に発せられます。
writeOperation キーのエクスポートにパスフレーズが必要な場合は「true 」、キーのインポートにパスフレーズが必要な場合は「false 」となります。
maximumLength パスフレーズの最大長(バイト単位)を指定します。passphrase 内のこの制限を超えるすべての文字は無視されます。
スレッドの境界を越えてこのシグナルを使用する場合は、Qt::BlockingQueuedConnection と接続する必要があります。
QByteArray QOpcUaKeyPair::privateKeyToByteArray(QOpcUaKeyPair::Cipher cipher, const QString &password) const
PEM形式でエンコードされた秘密鍵を返します。秘密鍵が存在しない場合は、空のバイト配列が返されます。
鍵の暗号化方式は、パラメータcipher およびpassword を使用して指定する必要があります。鍵を暗号化せずに保存するには、暗号化方式Cipher::Unencrypted を使用する必要があります。
QByteArray QOpcUaKeyPair::publicKeyToByteArray() const
公開鍵をバイト配列として返します。
QOpcUaKeyPair::KeyType QOpcUaKeyPair::type() const
現在のキーの型を返します。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.