@@ -1055,25 +1055,6 @@ public Object run() {
10551055 }
10561056 }
10571057
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-
10771058 // test if a token is present and initialize this provider for it if so.
10781059 // does nothing if no token is found
10791060 // called from constructor and by poller
@@ -1124,12 +1105,6 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
11241105 }
11251106 continue ;
11261107 }
1127- if (isLegacy (mechInfo )) {
1128- if (showInfo ) {
1129- System .out .println ("DISABLED due to legacy" );
1130- }
1131- continue ;
1132- }
11331108
11341109 // we do not know of mechs with the upper 32 bits set
11351110 if (longMech >>> 32 != 0 ) {
@@ -1144,9 +1119,25 @@ private void initToken(CK_SLOT_INFO slotInfo) throws PKCS11Exception {
11441119 if (ds == null ) {
11451120 continue ;
11461121 }
1122+ boolean allowLegacy = config .getAllowLegacy ();
11471123 for (Descriptor d : ds ) {
11481124 Integer oldMech = supportedAlgs .get (d );
11491125 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+ }
11501141 supportedAlgs .put (d , integerMech );
11511142 continue ;
11521143 }
0 commit comments