public void measure (String event) { time2 = System.currentTimeMillis(); if (Arrays.contains(Constants.LOG_LEVELS, 1)) { System.out.println((time2 - time1) + " " + event); } time1 = System.currentTimeMillis(); }
private static void checkNamedCurve(int[] namedCurves, int namedCurve) throws IOException { if (namedCurves != null && !Arrays.contains(namedCurves, namedCurve)) { /* * RFC 4492 4. [...] servers MUST NOT negotiate the use of an ECC cipher suite * unless they can complete the handshake while respecting the choice of curves * and compression techniques specified by the client. */ throw new TlsFatalAlert(AlertDescription.illegal_parameter); } }
public static void checkActualFormat(short[] localECPointFormats, short actualFormat) throws IOException { if (actualFormat != ECPointFormat.uncompressed && (localECPointFormats == null || !Arrays.contains(localECPointFormats, actualFormat))) { throw new TlsFatalAlert(AlertDescription.illegal_parameter); } }
private static short[] checkNameType(short[] nameTypesSeen, short nameType) { /* * RFC 6066 3. The ServerNameList MUST NOT contain more than one name of the same * name_type. */ if (!NameType.isValid(nameType) || Arrays.contains(nameTypesSeen, nameType)) { return null; } return Arrays.append(nameTypesSeen, nameType); } }
public short getSelectedCompressionMethod() throws IOException { short[] compressionMethods = getCompressionMethods(); for (int i = 0; i < compressionMethods.length; ++i) { if (Arrays.contains(offeredCompressionMethods, compressionMethods[i])) { return this.selectedCompressionMethod = compressionMethods[i]; } } throw new TlsFatalAlert(AlertDescription.handshake_failure); }
public static short[] readSupportedPointFormatsExtension(byte[] extensionData) throws IOException { short[] ecPointFormats = TlsUtils.decodeUint8ArrayWithUint8Length(extensionData); if (!Arrays.contains(ecPointFormats, ECPointFormat.uncompressed)) { /* * RFC 4492 5.1. If the Supported Point Formats Extension is indeed sent, it MUST * contain the value 0 (uncompressed) as one of the items in the list of point formats. */ throw new TlsFatalAlert(AlertDescription.illegal_parameter); } return ecPointFormats; }
public static byte[] createSupportedPointFormatsExtension(short[] ecPointFormats) throws IOException { if (ecPointFormats == null || !Arrays.contains(ecPointFormats, ECPointFormat.uncompressed)) { /* * RFC 4492 5.1. If the Supported Point Formats Extension is indeed sent, it MUST * contain the value 0 (uncompressed) as one of the items in the list of point formats. */ // NOTE: We add it at the end (lowest preference) ecPointFormats = Arrays.append(ecPointFormats, ECPointFormat.uncompressed); } return TlsUtils.encodeUint8ArrayWithUint8Length(ecPointFormats); }
public short getSelectedCompressionMethod() throws IOException { short[] compressionMethods = getCompressionMethods(); for (int i = 0; i < compressionMethods.length; ++i) { if (Arrays.contains(offeredCompressionMethods, compressionMethods[i])) { return this.selectedCompressionMethod = compressionMethods[i]; } } throw new TlsFatalAlert(AlertDescription.handshake_failure); }
public static byte[] createSupportedPointFormatsExtension(short[] ecPointFormats) throws IOException { if (ecPointFormats == null || !Arrays.contains(ecPointFormats, ECPointFormat.uncompressed)) { /* * RFC 4492 5.1. If the Supported Point Formats Extension is indeed sent, it MUST * contain the value 0 (uncompressed) as one of the items in the list of point formats. */ // NOTE: We add it at the end (lowest preference) ecPointFormats = Arrays.append(ecPointFormats, ECPointFormat.uncompressed); } return TlsUtils.encodeUint8ArrayWithUint8Length(ecPointFormats); }
private static short[] checkNameType(short[] nameTypesSeen, short nameType) { /* * RFC 6066 3. The ServerNameList MUST NOT contain more than one name of the same * name_type. */ if (!NameType.isValid(nameType) || Arrays.contains(nameTypesSeen, nameType)) { return null; } return Arrays.append(nameTypesSeen, nameType); } }
protected boolean isSelectableCipherSuite(int cipherSuite, int availCurveBits, Vector sigAlgs) { return Arrays.contains(this.offeredCipherSuites, cipherSuite) && TlsUtils.isValidCipherSuiteForVersion(cipherSuite, serverVersion) && availCurveBits >= TlsECCUtils.getMinimumCurveBits(cipherSuite) && TlsUtils.isValidCipherSuiteForSignatureAlgorithms(cipherSuite, sigAlgs); }
public static short[] readSupportedPointFormatsExtension(byte[] extensionData) throws IOException { if (extensionData == null) { throw new IllegalArgumentException("'extensionData' cannot be null"); } ByteArrayInputStream buf = new ByteArrayInputStream(extensionData); short length = TlsUtils.readUint8(buf); if (length < 1) { throw new TlsFatalAlert(AlertDescription.decode_error); } short[] ecPointFormats = TlsUtils.readUint8Array(length, buf); TlsProtocol.assertEmpty(buf); if (!Arrays.contains(ecPointFormats, ECPointFormat.uncompressed)) { /* * RFC 4492 5.1. If the Supported Point Formats Extension is indeed sent, it MUST * contain the value 0 (uncompressed) as one of the items in the list of point formats. */ throw new TlsFatalAlert(AlertDescription.illegal_parameter); } return ecPointFormats; }
if (Arrays.contains(this.offeredCipherSuites, cipherSuite) && (eccCipherSuitesEnabled || !TlsECCUtils.isECCCipherSuite(cipherSuite)) && TlsUtils.isValidCipherSuiteForVersion(cipherSuite, serverVersion)
&& (ecPointFormats == null || !Arrays.contains(ecPointFormats, actualFormat)))
if (!Arrays.contains(this.offeredCipherSuites, sessionParameters.getCipherSuite()) || !Arrays.contains(this.offeredCompressionMethods, sessionParameters.getCompressionAlgorithm())) boolean noRenegExt = (null == renegExtData); boolean noRenegSCSV = !Arrays.contains(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV); if (fallback && !Arrays.contains(offeredCipherSuites, CipherSuite.TLS_FALLBACK_SCSV))
if (!Arrays.contains(this.offeredCipherSuites, sessionParameters.getCipherSuite()) || !Arrays.contains(this.offeredCompressionMethods, sessionParameters.getCompressionAlgorithm())) boolean noRenegExt = (null == renegExtData); boolean noRenegSCSV = !Arrays.contains(offeredCipherSuites, CipherSuite.TLS_EMPTY_RENEGOTIATION_INFO_SCSV); if (fallback && !Arrays.contains(offeredCipherSuites, CipherSuite.TLS_FALLBACK_SCSV))