Пример #1
0
  /**
   * Does the actual work for decrypting - if version does not match current cipher then tries the
   * previous cipher
   */
  private Message decryptMessage(Cipher cipher, Message msg) throws Exception {
    EncryptHeader hdr = (EncryptHeader) msg.getHeader(this.id);
    if (!Arrays.equals(hdr.getVersion(), getSymVersion())) {
      log.warn(
          "attempting to use stored cipher as message does not use current encryption version ");
      cipher = keyMap.get(new AsciiString(hdr.getVersion()));
      if (cipher == null) {
        log.warn("unable to find a matching cipher in previous key map");
        return null;
      }
      log.trace("decrypting using previous cipher version");
      synchronized (cipher) {
        return _decrypt(cipher, msg, hdr.encryptEntireMessage());
      }
    }

    return _decrypt(cipher, msg, hdr.encryptEntireMessage());
  }