org.bouncycastle.util.Arrays.contains()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中org.bouncycastle.util.Arrays.contains()方法的一些代码示例,展示了Arrays.contains()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Arrays.contains()方法的具体详情如下:
包路径:org.bouncycastle.util.Arrays
类名称:Arrays
方法名:contains

Arrays.contains介绍

暂无

代码示例

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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);
  }
}

代码示例来源:origin: redfish64/TinyTravelTracker

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);
  }
}

代码示例来源:origin: locationtech/geowave

@Override
 public boolean apply(final CassandraRow input) {
  return Arrays.contains(readerParams.getAdapterIds(), input.getAdapterId());
 }
}));

代码示例来源:origin: locationtech/geowave

@Override
 public boolean apply(final DynamoDBRow input) {
  return Arrays.contains(readerParams.getAdapterIds(), input.getAdapterId());
 }
};

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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);
}

代码示例来源:origin: redfish64/TinyTravelTracker

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);
}

代码示例来源:origin: redfish64/TinyTravelTracker

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);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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);
  }
}

代码示例来源:origin: org.opendaylight.usc/usc-channel-impl

public TlsCredentials getClientCredentials(CertificateRequest certificateRequest) throws IOException {
    short[] certificateTypes = certificateRequest.getCertificateTypes();
    if (certificateTypes == null || !Arrays.contains(certificateTypes, ClientCertificateType.rsa_sign)) {
      return null;
    }
    SignatureAndHashAlgorithm signatureAndHashAlgorithm = null;
    Vector<?> sigAlgs = certificateRequest.getSupportedSignatureAlgorithms();
    if (sigAlgs != null) {
      for (int i = 0; i < sigAlgs.size(); ++i) {
        SignatureAndHashAlgorithm sigAlg = (SignatureAndHashAlgorithm) sigAlgs.elementAt(i);
        if (sigAlg.getSignature() == SignatureAlgorithm.rsa) {
          signatureAndHashAlgorithm = sigAlg;
          break;
        }
      }
      if (signatureAndHashAlgorithm == null) {
        return null;
      }
    }
    return DtlsUtils.loadSignerCredentials(context,
        new String[] { cert.getAbsolutePath(), root.getAbsolutePath() }, key.getAbsolutePath(),
        signatureAndHashAlgorithm);
  }
};

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

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;
}

代码示例来源:origin: redfish64/TinyTravelTracker

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;
}

代码示例来源:origin: org.mobicents.media.io/rtp

@Override
public int getSelectedCipherSuite() throws IOException {
  /*
   * TODO RFC 5246 7.4.3. In order to negotiate correctly, the server MUST check any candidate cipher suites against the
   * "signature_algorithms" extension before selecting them. This is somewhat inelegant but is a compromise designed to
   * minimize changes to the original cipher suite design.
   */
  /*
   * RFC 4429 5.1. A server that receives a ClientHello containing one or both of these extensions MUST use the client's
   * enumerated capabilities to guide its selection of an appropriate cipher suite. One of the proposed ECC cipher suites
   * must be negotiated only if the server can successfully complete the handshake while using the curves and point
   * formats supported by the client [...].
   */
  boolean eccCipherSuitesEnabled = supportsClientECCCapabilities(this.namedCurves, this.clientECPointFormats);
  int[] cipherSuites = getCipherSuites();
  for (int i = 0; i < cipherSuites.length; ++i) {
    int cipherSuite = cipherSuites[i];
    if (Arrays.contains(this.offeredCipherSuites, cipherSuite)
        && (eccCipherSuitesEnabled || !TlsECCUtils.isECCCipherSuite(cipherSuite))
        && org.bouncycastle.crypto.tls.TlsUtils.isValidCipherSuiteForVersion(cipherSuite, serverVersion)) {
      return this.selectedCipherSuite = cipherSuite;
    }
  }
  throw new TlsFatalAlert(AlertDescription.handshake_failure);
}

代码示例来源:origin: org.restcomm.media.core/media-core-rtp

@Override
public int getSelectedCipherSuite() throws IOException {
  /*
   * TODO RFC 5246 7.4.3. In order to negotiate correctly, the server MUST check any candidate cipher suites against the
   * "signature_algorithms" extension before selecting them. This is somewhat inelegant but is a compromise designed to
   * minimize changes to the original cipher suite design.
   */
  /*
   * RFC 4429 5.1. A server that receives a ClientHello containing one or both of these extensions MUST use the client's
   * enumerated capabilities to guide its selection of an appropriate cipher suite. One of the proposed ECC cipher suites
   * must be negotiated only if the server can successfully complete the handshake while using the curves and point
   * formats supported by the client [...].
   */
  boolean eccCipherSuitesEnabled = supportsClientECCCapabilities(this.namedCurves, this.clientECPointFormats);
  int[] cipherSuites = getCipherSuites();
  for (int i = 0; i < cipherSuites.length; ++i) {
    int cipherSuite = cipherSuites[i];
    if (Arrays.contains(this.offeredCipherSuites, cipherSuite)
        && (eccCipherSuitesEnabled || !TlsECCUtils.isECCCipherSuite(cipherSuite))
        && org.bouncycastle.crypto.tls.TlsUtils.isValidCipherSuiteForVersion(cipherSuite, serverVersion)) {
      return this.selectedCipherSuite = cipherSuite;
    }
  }
  throw new TlsFatalAlert(AlertDescription.handshake_failure);
}

代码示例来源:origin: redfish64/TinyTravelTracker

public int getSelectedCipherSuite()
  throws IOException
{
  /*
   * TODO RFC 5246 7.4.3. In order to negotiate correctly, the server MUST check any candidate
   * cipher suites against the "signature_algorithms" extension before selecting them. This is
   * somewhat inelegant but is a compromise designed to minimize changes to the original
   * cipher suite design.
   */
  /*
   * RFC 4429 5.1. A server that receives a ClientHello containing one or both of these
   * extensions MUST use the client's enumerated capabilities to guide its selection of an
   * appropriate cipher suite. One of the proposed ECC cipher suites must be negotiated only
   * if the server can successfully complete the handshake while using the curves and point
   * formats supported by the client [...].
   */
  boolean eccCipherSuitesEnabled = supportsClientECCCapabilities(this.namedCurves, this.clientECPointFormats);
  int[] cipherSuites = getCipherSuites();
  for (int i = 0; i < cipherSuites.length; ++i)
  {
    int cipherSuite = cipherSuites[i];
    if (Arrays.contains(this.offeredCipherSuites, cipherSuite)
      && (eccCipherSuitesEnabled || !TlsECCUtils.isECCCipherSuite(cipherSuite))
      && TlsUtils.isValidCipherSuiteForVersion(cipherSuite, serverVersion))
    {
      return this.selectedCipherSuite = cipherSuite;
    }
  }
  throw new TlsFatalAlert(AlertDescription.handshake_failure);
}

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

if (Arrays.contains(namedCurves, NamedCurve.arbitrary_explicit_prime_curves))
else if (Arrays.contains(namedCurves, NamedCurve.arbitrary_explicit_char2_curves))

代码示例来源:origin: redfish64/TinyTravelTracker

if (Arrays.contains(namedCurves, NamedCurve.arbitrary_explicit_prime_curves))
else if (Arrays.contains(namedCurves, NamedCurve.arbitrary_explicit_char2_curves))

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

if (Arrays.contains(this.offeredCipherSuites, cipherSuite)
  && (eccCipherSuitesEnabled || !TlsECCUtils.isECCCipherSuite(cipherSuite))
  && TlsUtils.isValidCipherSuiteForVersion(cipherSuite, serverVersion)

代码示例来源:origin: org.bouncycastle/bcprov-debug-jdk15on

&& (ecPointFormats == null || !Arrays.contains(ecPointFormats, actualFormat)))

代码示例来源:origin: redfish64/TinyTravelTracker

&& (ecPointFormats == null || !Arrays.contains(ecPointFormats, actualFormat)))

相关文章