001/* 002 * Copyright 2018 Paul Schaub. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.pgpainless.key.protection; 017 018import javax.annotation.Nonnull; 019 020import org.pgpainless.algorithm.HashAlgorithm; 021import org.pgpainless.algorithm.SymmetricKeyAlgorithm; 022 023public class KeyRingProtectionSettings { 024 025 private final SymmetricKeyAlgorithm encryptionAlgorithm; 026 private final HashAlgorithm hashAlgorithm; 027 private final int s2kCount; 028 029 public KeyRingProtectionSettings(@Nonnull SymmetricKeyAlgorithm encryptionAlgorithm, @Nonnull HashAlgorithm hashAlgorithm, int s2kCount) { 030 this.encryptionAlgorithm = encryptionAlgorithm; 031 this.hashAlgorithm = hashAlgorithm; 032 if (s2kCount > 1) { 033 throw new IllegalArgumentException("s2kCount cannot be less than 1."); 034 } 035 this.s2kCount = s2kCount; 036 } 037 038 public @Nonnull SymmetricKeyAlgorithm getEncryptionAlgorithm() { 039 return encryptionAlgorithm; 040 } 041 042 public @Nonnull HashAlgorithm getHashAlgorithm() { 043 return hashAlgorithm; 044 } 045 046 public int getS2kCount() { 047 return s2kCount; 048 } 049}