@@ -1055,25 +1055,6 @@ public Object run() {
1055
1055
}
1056
1056
}
1057
1057
1058
- private static boolean isLegacy (CK_MECHANISM_INFO mechInfo )
1059
- throws PKCS11Exception {
1060
- // assume full support if no mech info available
1061
- // For vendor-specific mechanisms, often no mech info is provided
1062
- boolean partialSupport = false ;
1063
-
1064
- if (mechInfo != null ) {
1065
- if ((mechInfo .flags & CKF_DECRYPT ) != 0 ) {
1066
- // non-legacy cipher mechs should support encryption
1067
- partialSupport |= ((mechInfo .flags & CKF_ENCRYPT ) == 0 );
1068
- }
1069
- if ((mechInfo .flags & CKF_VERIFY ) != 0 ) {
1070
- // non-legacy signature mechs should support signing
1071
- partialSupport |= ((mechInfo .flags & CKF_SIGN ) == 0 );
1072
- }
1073
- }
1074
- return partialSupport ;
1075
- }
1076
-
1077
1058
// test if a token is present and initialize this provider for it if so.
1078
1059
// does nothing if no token is found
1079
1060
// called from constructor and by poller
@@ -1124,12 +1105,6 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1124
1105
}
1125
1106
continue ;
1126
1107
}
1127
- if (isLegacy (mechInfo )) {
1128
- if (showInfo ) {
1129
- System .out .println ("DISABLED due to legacy" );
1130
- }
1131
- continue ;
1132
- }
1133
1108
1134
1109
// we do not know of mechs with the upper 32 bits set
1135
1110
if (longMech >>> 32 != 0 ) {
@@ -1144,9 +1119,25 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1144
1119
if (ds == null ) {
1145
1120
continue ;
1146
1121
}
1122
+ boolean allowLegacy = config .getAllowLegacy ();
1147
1123
for (Descriptor d : ds ) {
1148
1124
Integer oldMech = supportedAlgs .get (d );
1149
1125
if (oldMech == null ) {
1126
+
1127
+ // assume full support if no mech info available
1128
+ if (!allowLegacy && mechInfo != null ) {
1129
+ if ((d .type == CIP &&
1130
+ (mechInfo .flags & CKF_ENCRYPT ) == 0 ) ||
1131
+ (d .type == SIG &&
1132
+ (mechInfo .flags & CKF_SIGN ) == 0 )) {
1133
+ if (showInfo ) {
1134
+ System .out .println ("DISABLED " + d .type +
1135
+ " " + d .algorithm +
1136
+ " due to partial support" );
1137
+ }
1138
+ continue ;
1139
+ }
1140
+ }
1150
1141
supportedAlgs .put (d , integerMech );
1151
1142
continue ;
1152
1143
}
0 commit comments