@@ -1212,25 +1212,6 @@ public Object run() {
1212
1212
}
1213
1213
}
1214
1214
1215
- private static boolean isLegacy (CK_MECHANISM_INFO mechInfo )
1216
- throws PKCS11Exception {
1217
- // assume full support if no mech info available
1218
- // For vendor-specific mechanisms, often no mech info is provided
1219
- boolean partialSupport = false ;
1220
-
1221
- if (mechInfo != null ) {
1222
- if ((mechInfo .flags & CKF_DECRYPT ) != 0 ) {
1223
- // non-legacy cipher mechs should support encryption
1224
- partialSupport |= ((mechInfo .flags & CKF_ENCRYPT ) == 0 );
1225
- }
1226
- if ((mechInfo .flags & CKF_VERIFY ) != 0 ) {
1227
- // non-legacy signature mechs should support signing
1228
- partialSupport |= ((mechInfo .flags & CKF_SIGN ) == 0 );
1229
- }
1230
- }
1231
- return partialSupport ;
1232
- }
1233
-
1234
1215
// test if a token is present and initialize this provider for it if so.
1235
1216
// does nothing if no token is found
1236
1217
// called from constructor and by poller
@@ -1281,12 +1262,6 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1281
1262
}
1282
1263
continue ;
1283
1264
}
1284
- if (isLegacy (mechInfo )) {
1285
- if (showInfo ) {
1286
- System .out .println ("DISABLED due to legacy" );
1287
- }
1288
- continue ;
1289
- }
1290
1265
1291
1266
// we do not know of mechs with the upper 32 bits set
1292
1267
if (longMech >>> 32 != 0 ) {
@@ -1301,6 +1276,7 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1301
1276
if (ds == null ) {
1302
1277
continue ;
1303
1278
}
1279
+ boolean allowLegacy = config .getAllowLegacy ();
1304
1280
descLoop :
1305
1281
for (Descriptor d : ds ) {
1306
1282
Integer oldMech = supportedAlgs .get (d );
@@ -1316,6 +1292,21 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
1316
1292
}
1317
1293
}
1318
1294
}
1295
+
1296
+ // assume full support if no mech info available
1297
+ if (!allowLegacy && mechInfo != null ) {
1298
+ if ((d .type == CIP &&
1299
+ (mechInfo .flags & CKF_ENCRYPT ) == 0 ) ||
1300
+ (d .type == SIG &&
1301
+ (mechInfo .flags & CKF_SIGN ) == 0 )) {
1302
+ if (showInfo ) {
1303
+ System .out .println ("DISABLED " + d .type +
1304
+ " " + d .algorithm +
1305
+ " due to partial support" );
1306
+ }
1307
+ continue ;
1308
+ }
1309
+ }
1319
1310
supportedAlgs .put (d , integerMech );
1320
1311
continue ;
1321
1312
}
0 commit comments