001/* 002 * nimbus-jose-jwt 003 * 004 * Copyright 2012-2016, Connect2id Ltd and contributors. 005 * 006 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use 007 * this file except in compliance with the License. You may obtain a copy of the 008 * License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software distributed 013 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 014 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 015 * specific language governing permissions and limitations under the License. 016 */ 017 018package com.nimbusds.jose.crypto.impl; 019 020 021import com.nimbusds.jose.JWSAlgorithm; 022import com.nimbusds.jose.jwk.Curve; 023 024import java.util.Arrays; 025import java.util.Collections; 026import java.util.HashSet; 027import java.util.Set; 028 029 030/** 031 * The base abstract class for Edwards-curve Digital Signature Algorithm 032 * (EdDSA) signers and validators of {@link com.nimbusds.jose.JWSObject JWS 033 * objects}. 034 * 035 * <p>Supports the following algorithm: 036 * 037 * <ul> 038 * <li>{@link com.nimbusds.jose.JWSAlgorithm#Ed25519} 039 * <li>{@link com.nimbusds.jose.JWSAlgorithm#EdDSA} with 040 * {@link com.nimbusds.jose.jwk.Curve#Ed25519} 041 * </ul> 042 * 043 * @author Tim McLean 044 * @version 2024-05-07 045 */ 046public abstract class EdDSAProvider extends BaseJWSProvider { 047 048 049 /** 050 * The supported JWS algorithms by the EdDSA provider class. 051 */ 052 public static final Set<JWSAlgorithm> SUPPORTED_ALGORITHMS; 053 054 055 /** 056 * The supported curves by the EdDSA provider class. 057 */ 058 public static final Set<Curve> SUPPORTED_CURVES; 059 060 061 static { 062 SUPPORTED_ALGORITHMS = Collections.unmodifiableSet( 063 new HashSet<>( 064 Arrays.asList( 065 JWSAlgorithm.EdDSA, 066 JWSAlgorithm.Ed25519 067 ) 068 )); 069 070 SUPPORTED_CURVES = Collections.singleton(Curve.Ed25519); 071 } 072 073 074 /** 075 * Creates a new Edwards-curve Digital Signature Algorithm (EdDSA) 076 * provider. 077 */ 078 protected EdDSAProvider() { 079 080 super(SUPPORTED_ALGORITHMS); 081 } 082} 083