コード例 #1
0
  public Key getJceKey(ASN1ObjectIdentifier algorithm, GenericKey key) {
    if (key.getRepresentation() instanceof Key) {
      return (Key) key.getRepresentation();
    }

    if (key.getRepresentation() instanceof byte[]) {
      return new SecretKeySpec((byte[]) key.getRepresentation(), getBaseCipherName(algorithm));
    }

    throw new IllegalArgumentException("unknown generic key type");
  }
コード例 #2
0
  Key getJceKey(GenericKey key) {
    if (key.getRepresentation() instanceof Key) {
      return (Key) key.getRepresentation();
    }

    if (key.getRepresentation() instanceof byte[]) {
      return new SecretKeySpec((byte[]) key.getRepresentation(), "ENC");
    }

    throw new IllegalArgumentException("unknown generic key type");
  }