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

UNCONFIRMED
Unassigned

Status

UNCONFIRMED
9 years ago
9 years ago

People

(Reporter: bob.e.foss, Unassigned)

Tracking

Details

(Reporter)

Description

9 years ago
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
(Reporter)

Updated

9 years ago
Version: unspecified → 4.3

Updated

9 years ago
Assignee: gbmozilla → nobody
You need to log in before you can comment on or make changes to this bug.