private static int getBlockSecretSetSize(ProtocolVersion protocolVersion, CipherSuite cipherSuite) { CipherAlgorithm cipherAlg = AlgorithmResolver.getCipher(cipherSuite); int keySize = cipherAlg.getKeySize(); MacAlgorithm macAlg = AlgorithmResolver.getMacAlgorithm(protocolVersion, cipherSuite); int secretSetSize = (2 * keySize) + (2 * macAlg.getKeySize()); if (!protocolVersion.usesExplicitIv()) { secretSetSize += (2 * cipherAlg.getNonceBytesFromHandshake()); } return secretSetSize; }
private static int getStreamSecretSetSize(ProtocolVersion protocolVersion, CipherSuite cipherSuite) { CipherAlgorithm cipherAlg = AlgorithmResolver.getCipher(cipherSuite); MacAlgorithm macAlg = AlgorithmResolver.getMacAlgorithm(protocolVersion, cipherSuite); int secretSetSize = (2 * cipherAlg.getKeySize()) + (2 * macAlg.getKeySize()); if (cipherSuite.isSteamCipherWithIV()) { secretSetSize += (2 * cipherAlg.getNonceBytesFromHandshake()); } return secretSetSize; }
private static int getAeadSecretSetSize(ProtocolVersion protocolVersion, CipherSuite cipherSuite) { CipherAlgorithm cipherAlg = AlgorithmResolver.getCipher(cipherSuite); int keySize = cipherAlg.getKeySize(); // GCM in TLS uses 4 bytes long salt (generated in the handshake), // 8 bytes long nonce (changed for each new record), and 4 bytes long // sequence number used increased in the record int saltSize = RecordAEADCipher.GCM_IV_LENGTH - RecordAEADCipher.SEQUENCE_NUMBER_LENGTH; int secretSetSize = 2 * keySize + 2 * saltSize; return secretSetSize; }
private int getKeySize() { if (suite.isExportSymmetricCipher()) { return CipherSuite.EXPORT_SYMMETRIC_KEY_SIZE_BYTES; } else { return AlgorithmResolver.getCipher(suite).getKeySize(); } }
public String getJavaName() { String hashAlgorithmName = getHashAlgorithm().getJavaName(); if (!hashAlgorithmName.contains("GOST")) { hashAlgorithmName = hashAlgorithmName.replace("-", ""); } String signatureAlgorithmName = getSignatureAlgorithm().getJavaName(); return hashAlgorithmName + "with" + signatureAlgorithmName; }
@Override public String toString() { return "AlertDescription{" + "value=" + getAlertDescription(value).name() + '}'; } }
private int getMacKeySize() { return AlgorithmResolver.getMacAlgorithm(version, suite).getKeySize(); }
private int getIVSize() { return AlgorithmResolver.getCipher(suite).getNonceBytesFromHandshake(); }
/** * Return true, if protocol version TLS 1.3 * * @return True if protocolVersion is TLS.13 or a Draft of TLS 1.3 */ public boolean isTLS13() { return this == TLS13 || this.getMajor() == 0x7F; }
@Override public int getBlocksize() { return algorithm.getBlocksize(); }
public static SignatureAndHashAlgorithm getSignatureAndHashAlgorithm(byte[] value) { return getSignatureAndHashAlgorithm(valueToInt(value)); }
/** * Returns true if the cipher suite a TLS 1.3 cipher suite * * @return True if the Ciphersuite is supported in TLS 1.3 */ public boolean isTLS13() { return this.getByteValue()[0] == (byte) 0x13 && this.getByteValue()[1] != (byte) 0x00; }
public String getJavaName() { if (this == DES40) { return "DES"; } return this.toString(); } }
private CipherSuite choosePskCipherSuite(List<CipherSuite> cipherSuiteList) { for (CipherSuite suite : cipherSuiteList) { if (suite.isPsk()) { return suite; } } return null; }
/** * @param cipherSuite * The Ciphersuite for which the BulkCipherAlgorithm should be * returned * @return The BulkCipherAlgorithm of the Cipher */ public static BulkCipherAlgorithm getBulkCipherAlgorithm(CipherSuite cipherSuite) { return BulkCipherAlgorithm.getBulkCipherAlgorithm(cipherSuite); }
@Override public String toString() { return "AlertLevel{" + "value=" + this.name() + '}'; }
public String getName() { return this.name(); } }
@Override public String toCompactString() { return handshakeMessageType.getName(); }
public boolean isStandardCurve() { return this.isCurve() && this != ECDH_X25519 && this != ECDH_X448; }