Closed Bug 526669 Opened 15 years ago Closed 2 years ago

Cipher.getBlockSize() does not return a value until Cipher is initialized

Categories

(JSS Graveyard :: Library, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: bob.e.foss, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.4; en-US; rv:1.9.1.4) Gecko/20091016 Firefox/3.5.4
Build Identifier: 4.3 RTM (with NSPR 4.8 and NSS 3.12.4)

SunJCE returns block sizes for AES (16), DES (8), DESede (8), and RC2 (8)
before the Cipher is initialized.  The Mozilla-JSS JCE provider
returns 0 until the Cipher is initialized.

Sample code.  Pass an argument like "AES/CBC/NoPadding" on the command line.

import javax.crypto.Cipher;
import org.mozilla.jss.CryptoManager;


public class BlockSize {

  public static void main(String[] args)
    throws Exception {

    String cipherName = args[0];

    CryptoManager.InitializationValues initializationValues = new CryptoManager.InitializationValues(".");
    initializationValues.fipsMode = CryptoManager.InitializationValues.FIPSMode.DISABLED;
    CryptoManager.initialize(initializationValues);

    int blockSizeSunJce = getBlockSize(cipherName, "SunJCE");
    int blockSizeMozillaJss = getBlockSize(cipherName, "Mozilla-JSS");

    System.out.println("SunJCE: " + blockSizeSunJce);
    System.out.println("Mozilla-JSS: " + blockSizeMozillaJss);
  }

  
  public static int getBlockSize(String cipherName, String provider) 
    throws Exception {

    Cipher cipher = Cipher.getInstance(cipherName, provider);
    return cipher.getBlockSize();
  }
}


Reproducible: Always
Version: unspecified → 4.3
Assignee: gbmozilla → nobody
JSS development has moved from the Mozilla community to the Dogtag PKI community. Please re-file this bug at https://github.com/dogtagpki/jss if it is still relevant. Thank you!
Status: UNCONFIRMED → RESOLVED
Closed: 2 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.