@@ -1222,25 +1222,6 @@ public Object run() {
1222
1222
}
1223
1223
}
1224
1224
1225
- private static boolean isLegacy (CK_MECHANISM_INFO mechInfo )
1226
- throws PKCS11Exception {
1227
- // assume full support if no mech info available
1228
- // For vendor-specific mechanisms, often no mech info is provided
1229
- boolean partialSupport = false ;
1230
-
1231
- if (mechInfo != null ) {
1232
- if ((mechInfo .flags & CKF_DECRYPT ) != 0 ) {
1233
- // non-legacy cipher mechs should support encryption
1234
- partialSupport |= ((mechInfo .flags & CKF_ENCRYPT ) == 0 );
1235
- }
1236
- if ((mechInfo .flags & CKF_VERIFY ) != 0 ) {
1237
- // non-legacy signature mechs should support signing
1238
- partialSupport |= ((mechInfo .flags & CKF_SIGN ) == 0 );
1239
- }
1240
- }
1241
- return partialSupport ;
1242
- }
1243
-
1244
1225
// test if a token is present and initialize this provider for it if so.
1245
1226
// does nothing if no token is found
1246
1227
// called from constructor and by poller
@@ -1309,12 +1290,6 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1309
1290
}
1310
1291
continue ;
1311
1292
}
1312
- if (isLegacy (mechInfo )) {
1313
- if (showInfo ) {
1314
- System .out .println ("DISABLED due to legacy" );
1315
- }
1316
- continue ;
1317
- }
1318
1293
1319
1294
if (brokenMechanisms .contains (longMech )) {
1320
1295
if (showInfo ) {
@@ -1336,6 +1311,7 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1336
1311
if (ds == null ) {
1337
1312
continue ;
1338
1313
}
1314
+ boolean allowLegacy = config .getAllowLegacy ();
1339
1315
descLoop :
1340
1316
for (Descriptor d : ds ) {
1341
1317
Integer oldMech = supportedAlgs .get (d );
@@ -1351,6 +1327,21 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1351
1327
}
1352
1328
}
1353
1329
}
1330
+
1331
+ // assume full support if no mech info available
1332
+ if (!allowLegacy && mechInfo != null ) {
1333
+ if ((d .type == CIP &&
1334
+ (mechInfo .flags & CKF_ENCRYPT ) == 0 ) ||
1335
+ (d .type == SIG &&
1336
+ (mechInfo .flags & CKF_SIGN ) == 0 )) {
1337
+ if (showInfo ) {
1338
+ System .out .println ("DISABLED " + d .type +
1339
+ " " + d .algorithm +
1340
+ " due to partial support" );
1341
+ }
1342
+ continue ;
1343
+ }
1344
+ }
1354
1345
supportedAlgs .put (d , integerMech );
1355
1346
continue ;
1356
1347
}
0 commit comments