AlgorithmConstraints — 알고리즘 제약 인터페이스

AlgorithmConstraints — 알고리즘 제약 인터페이스

암호화 알고리즘, 키(키 크기), 기타 알고리즘 파라미터에 대한 제약 조건을 지정하는 인터페이스예요. AlgorithmConstraints 객체는 불변(immutable)이에요. 이 인터페이스의 구현은 생성된 후 인스턴스의 상태를 바꿀 수 있는 메서드를 제공하면 안 돼요.

출처: Java API Reference

본문

보안 속성 jdk.certpath.disabledAlgorithmsjdk.tls.disabledAlgorithms로 설명되는 제한을 표현하는 데 사용할 수 있어요. 또는 구체적인 PKIXCertPathChecker가 인증 경로의 지정된 인증서에 필요한 알고리즘 제약이 포함되어 있는지 검사하는 데 사용할 수도 있어요.

  • boolean permits(Set<CryptoPrimitive> primitives, String algorithm, AlgorithmParameterSpec parameters) — 주어진 암호화 기본 요소와 알고리즘 이름, 파라미터가 이 제약 조건을 만족하는지 여부를 반환해요.
  • boolean permits(Set<CryptoPrimitive> primitives, Key key) — 주어진 키가 이 제약 조건을 만족하는지 여부를 반환해요.
  • boolean permits(Set<CryptoPrimitive> primitives, String algorithm, Key key, AlgorithmParameterSpec parameters) — 주어진 알고리즘·키·파라미터 조합이 이 제약 조건을 만족하는지 여부를 반환해요.
AlgorithmConstraints constraints = new DisabledAlgorithmConstraints("jdk.tls.disabledAlgorithms");
boolean ok = constraints.permits(Set.of(CryptoPrimitive.SIGNATURE), "SHA256withRSA", key);

더 알아보기 (Learn more)