@@ -1212,25 +1212,6 @@ public Object run() {
12121212 }
12131213 }
12141214
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-
12341215 // test if a token is present and initialize this provider for it if so.
12351216 // does nothing if no token is found
12361217 // called from constructor and by poller
@@ -1281,12 +1262,6 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
12811262 }
12821263 continue ;
12831264 }
1284- if (isLegacy (mechInfo )) {
1285- if (showInfo ) {
1286- System .out .println ("DISABLED due to legacy" );
1287- }
1288- continue ;
1289- }
12901265
12911266 // we do not know of mechs with the upper 32 bits set
12921267 if (longMech >>> 32 != 0 ) {
@@ -1301,6 +1276,7 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
13011276 if (ds == null ) {
13021277 continue ;
13031278 }
1279+ boolean allowLegacy = config .getAllowLegacy ();
13041280 descLoop :
13051281 for (Descriptor d : ds ) {
13061282 Integer oldMech = supportedAlgs .get (d );
@@ -1316,6 +1292,21 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
13161292 }
13171293 }
13181294 }
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+ }
13191310 supportedAlgs .put (d , integerMech );
13201311 continue ;
13211312 }
0 commit comments