@@ -956,25 +956,6 @@ public Object run() {
956
956
}
957
957
}
958
958
959
- private static boolean isLegacy (CK_MECHANISM_INFO mechInfo )
960
- throws PKCS11Exception {
961
- // assume full support if no mech info available
962
- // For vendor-specific mechanisms, often no mech info is provided
963
- boolean partialSupport = false ;
964
-
965
- if (mechInfo != null ) {
966
- if ((mechInfo .flags & CKF_DECRYPT ) != 0 ) {
967
- // non-legacy cipher mechs should support encryption
968
- partialSupport |= ((mechInfo .flags & CKF_ENCRYPT ) == 0 );
969
- }
970
- if ((mechInfo .flags & CKF_VERIFY ) != 0 ) {
971
- // non-legacy signature mechs should support signing
972
- partialSupport |= ((mechInfo .flags & CKF_SIGN ) == 0 );
973
- }
974
- }
975
- return partialSupport ;
976
- }
977
-
978
959
// test if a token is present and initialize this provider for it if so.
979
960
// does nothing if no token is found
980
961
// called from constructor and by poller
@@ -1025,12 +1006,6 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1025
1006
}
1026
1007
continue ;
1027
1008
}
1028
- if (isLegacy (mechInfo )) {
1029
- if (showInfo ) {
1030
- System .out .println ("DISABLED due to legacy" );
1031
- }
1032
- continue ;
1033
- }
1034
1009
1035
1010
// we do not know of mechs with the upper 32 bits set
1036
1011
if (longMech >>> 32 != 0 ) {
@@ -1045,9 +1020,25 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1045
1020
if (ds == null ) {
1046
1021
continue ;
1047
1022
}
1023
+ boolean allowLegacy = config .getAllowLegacy ();
1048
1024
for (Descriptor d : ds ) {
1049
1025
Integer oldMech = supportedAlgs .get (d );
1050
1026
if (oldMech == null ) {
1027
+
1028
+ // assume full support if no mech info available
1029
+ if (!allowLegacy && mechInfo != null ) {
1030
+ if ((d .type == CIP &&
1031
+ (mechInfo .flags & CKF_ENCRYPT ) == 0 ) ||
1032
+ (d .type == SIG &&
1033
+ (mechInfo .flags & CKF_SIGN ) == 0 )) {
1034
+ if (showInfo ) {
1035
+ System .out .println ("DISABLED " + d .type +
1036
+ " " + d .algorithm +
1037
+ " due to partial support" );
1038
+ }
1039
+ continue ;
1040
+ }
1041
+ }
1051
1042
supportedAlgs .put (d , integerMech );
1052
1043
continue ;
1053
1044
}
0 commit comments