Uploaded image for project: 'Commons Crypto'
  1. Commons Crypto
  2. CRYPTO-77

Hide Stream's Ctor with cipher parameter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      Stream has such two Ctor:

      // denoted as (a)
      public CryptoInputStream(InputStream in, CryptoCipher cipher,
                  int bufferSize, Key key, AlgorithmParameterSpec params)
      
      // denoted as (b)
      public CryptoInputStream(CipherTransformation transformation,
                  Properties props, InputStream in, Key key,
                  AlgorithmParameterSpec params)
      

      if use Ctor (b), client user don't have to construct a cipher. make sense.

      But, in Ctor (a), the cipher argument is create outside Ctor, then it is initialized in CryptoInputStream's Ctor. The cipher’s construction is scattered. It is a bit confusing.
      Ctor (a) seem only used internally. It would be better to hide Ctor (a) for user.

      In future, we can consider this:

      // don't pass key and iv param, the cipher should be initialized outside
      // similar to JDK, and more scalable to support GCM, CCM modes.
      CryptoInputStream(InputStream in, CryptoCipher cipher,  int bufferSize)
      

      right now, we just hide Ctor (a) for user.

      Attachments

        Activity

          People

            kexianda Xianda Ke
            kexianda Xianda Ke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: