public void init(Map attributes) throws InvalidKeyException {
      synchronized(lock) {
         if (currentKey != null) {
            throw new IllegalStateException();
         }

         Integer bs = (Integer) attributes.get(CIPHER_BLOCK_SIZE);
         if (bs == null) { // no block size was specified.
            if (currentBlockSize == 0) { // happy birthday
               currentBlockSize = defaultBlockSize;
            } // else it's a clone. use as is
         } else {
            currentBlockSize = bs.intValue();
            // ensure that value is valid
            Iterator it;
            boolean ok = false;
            for (it = blockSizes(); it.hasNext(); ) {
               ok = (currentBlockSize == ((Integer) it.next()).intValue());
               if (ok) {
                  break;
               }
            }
            if (!ok) {
               throw new IllegalArgumentException(IBlockCipher.CIPHER_BLOCK_SIZE);
            }
         }

         byte[] k = (byte[]) attributes.get(KEY_MATERIAL);
         currentKey = makeKey(k, currentBlockSize);
      }
   }