@@ -937,11 +937,81 @@ std::optional<QByteArray> decryptStringAsymmetricWithToken(ENGINE *sslEngine, PK
937
937
}
938
938
939
939
940
- ClientSideEncryption::ClientSideEncryption ()
940
+ ClientSideEncryption::ClientSideEncryption () = default ;
941
+
942
+ const QSslKey &ClientSideEncryption::getPublicKey () const
943
+ {
944
+ return _publicKey;
945
+ }
946
+
947
+ void ClientSideEncryption::setPublicKey (const QSslKey &publicKey)
948
+ {
949
+ _publicKey = publicKey;
950
+ }
951
+
952
+ const QByteArray &ClientSideEncryption::getPrivateKey () const
953
+ {
954
+ return _privateKey;
955
+ }
956
+
957
+ void ClientSideEncryption::setPrivateKey (const QByteArray &privateKey)
958
+ {
959
+ _privateKey = privateKey;
960
+ }
961
+
962
+ PKCS11_KEY* ClientSideEncryption::getTokenPublicKey () const
963
+ {
964
+ return _tokenPublicKey;
965
+ }
966
+
967
+ PKCS11_KEY* ClientSideEncryption::getTokenPrivateKey () const
968
+ {
969
+ return _tokenPrivateKey;
970
+ }
971
+
972
+ bool ClientSideEncryption::useTokenBasedEncryption () const
973
+ {
974
+ return _tokenPublicKey && _tokenPrivateKey;
975
+ }
976
+
977
+ const QString &ClientSideEncryption::getMnemonic () const
978
+ {
979
+ return _mnemonic;
980
+ }
981
+
982
+ void ClientSideEncryption::setCertificate (const QSslCertificate &certificate)
983
+ {
984
+ _certificate = certificate;
985
+ }
986
+
987
+ ENGINE* ClientSideEncryption::sslEngine () const
988
+ {
989
+ return ENGINE_get_default_RSA ();
990
+ }
991
+
992
+ void ClientSideEncryption::initialize (const AccountPtr &account)
993
+ {
994
+ Q_ASSERT (account);
995
+
996
+ if (account->useHardwareTokenEncryption ()) {
997
+ initializeHardwareTokenEncryption (account);
998
+ }
999
+
1000
+ qCInfo (lcCse ()) << " Initializing" ;
1001
+ if (!account->capabilities ().clientSideEncryptionAvailable ()) {
1002
+ qCInfo (lcCse ()) << " No Client side encryption available on server." ;
1003
+ emit initializationFinished ();
1004
+ return ;
1005
+ }
1006
+
1007
+ fetchCertificateFromKeyChain (account);
1008
+ }
1009
+
1010
+ void ClientSideEncryption::initializeHardwareTokenEncryption (const AccountPtr &account)
941
1011
{
942
1012
auto ctx = PKCS11_CTX_new ();
943
1013
944
- auto rc = PKCS11_CTX_load (ctx, " " );
1014
+ auto rc = PKCS11_CTX_load (ctx, account-> encryptionHardwareTokenDriverPath (). toLatin1 (). constData () );
945
1015
if (rc) {
946
1016
qCWarning (lcCse ()) << " loading pkcs11 engine failed:" << ERR_reason_error_string (ERR_get_error ());
947
1017
rc = 1 ;
@@ -1047,70 +1117,6 @@ ClientSideEncryption::ClientSideEncryption()
1047
1117
<< " need login:" << (tokenPublicKey->needLogin ? " true" : " false" );
1048
1118
}
1049
1119
1050
- const QSslKey &ClientSideEncryption::getPublicKey () const
1051
- {
1052
- return _publicKey;
1053
- }
1054
-
1055
- void ClientSideEncryption::setPublicKey (const QSslKey &publicKey)
1056
- {
1057
- _publicKey = publicKey;
1058
- }
1059
-
1060
- const QByteArray &ClientSideEncryption::getPrivateKey () const
1061
- {
1062
- return _privateKey;
1063
- }
1064
-
1065
- void ClientSideEncryption::setPrivateKey (const QByteArray &privateKey)
1066
- {
1067
- _privateKey = privateKey;
1068
- }
1069
-
1070
- PKCS11_KEY* ClientSideEncryption::getTokenPublicKey () const
1071
- {
1072
- return _tokenPublicKey;
1073
- }
1074
-
1075
- PKCS11_KEY* ClientSideEncryption::getTokenPrivateKey () const
1076
- {
1077
- return _tokenPrivateKey;
1078
- }
1079
-
1080
- bool ClientSideEncryption::useTokenBasedEncryption () const
1081
- {
1082
- return _tokenPublicKey && _tokenPrivateKey;
1083
- }
1084
-
1085
- const QString &ClientSideEncryption::getMnemonic () const
1086
- {
1087
- return _mnemonic;
1088
- }
1089
-
1090
- void ClientSideEncryption::setCertificate (const QSslCertificate &certificate)
1091
- {
1092
- _certificate = certificate;
1093
- }
1094
-
1095
- ENGINE* ClientSideEncryption::sslEngine () const
1096
- {
1097
- return ENGINE_get_default_RSA ();
1098
- }
1099
-
1100
- void ClientSideEncryption::initialize (const AccountPtr &account)
1101
- {
1102
- Q_ASSERT (account);
1103
-
1104
- qCInfo (lcCse ()) << " Initializing" ;
1105
- if (!account->capabilities ().clientSideEncryptionAvailable ()) {
1106
- qCInfo (lcCse ()) << " No Client side encryption available on server." ;
1107
- emit initializationFinished ();
1108
- return ;
1109
- }
1110
-
1111
- fetchCertificateFromKeyChain (account);
1112
- }
1113
-
1114
1120
void ClientSideEncryption::fetchCertificateFromKeyChain (const AccountPtr &account)
1115
1121
{
1116
1122
const QString kck = AbstractCredentials::keychainKey (
0 commit comments