bcprov-jdk15on-149

shAlgorithm
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class KeyExchangeAlgorithm
{
  public static final int NULL = 0;
  public static final int RSA = 1;
  public static final int RSA_EXPORT = 2;
  public static final int DHE_DSS = 3;
  public static final int DHE_DSS_EXPORT = 4;
  public static final int DHE_RSA = 5;
  public static final int DHE_RSA_EXPORT = 6;
  public static final int DH_DSS = 7;
  public static final int DH_DSS_EXPORT = 8;
  public static final int DH_RSA = 9;
  public static final int DH_RSA_EXPORT = 10;
  public static final int DH_anon = 11;
  public static final int DH_anon_EXPORT = 12;
  public static final int PSK = 13;
  public static final int DHE_PSK = 14;
  public static final int RSA_PSK = 15;
  public static final int ECDH_ECDSA = 16;
  public static final int ECDHE_ECDSA = 17;
  public static final int ECDH_RSA = 18;
  public static final int ECDHE_RSA = 19;
  public static final int ECDH_anon = 20;
  public static final int SRP = 21;
  public static final int SRP_DSS = 22;
  public static final int SRP_RSA = 23;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.KeyExchangeAlgorithm
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;

/**
 * @deprecated
 */
public class LegacyTlsAuthentication
  extends ServerOnlyTlsAuthentication
{
  protected CertificateVerifyer verifyer;
  
  public LegacyTlsAuthentication(CertificateVerifyer paramCertificateVerifyer)
  {
    verifyer = paramCertificateVerifyer;
  }
  
  public void notifyServerCertificate(Certificate paramCertificate)
    throws IOException
  {
    if (!verifyer.isValid(paramCertificate.getCertificateList())) {
      throw new TlsFatalAlert((short)90);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.LegacyTlsAuthentication
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;

/**
 * @deprecated
 */
public class LegacyTlsClient
  extends DefaultTlsClient
{
  /**
   * @deprecated
   */
  protected CertificateVerifyer verifyer;
  
  /**
   * @deprecated
   */
  public LegacyTlsClient(CertificateVerifyer paramCertificateVerifyer)
  {
    verifyer = paramCertificateVerifyer;
  }
  
  public TlsAuthentication getAuthentication()
    throws IOException
  {
    return new LegacyTlsAuthentication(verifyer);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.LegacyTlsClient
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class MACAlgorithm
{
  public static final int _null = 0;
  public static final int md5 = 1;
  public static final int sha = 2;
  public static final int hmac_md5 = 1;
  public static final int hmac_sha1 = 2;
  public static final int hmac_sha256 = 3;
  public static final int hmac_sha384 = 4;
  public static final int hmac_sha512 = 5;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.MACAlgorithm
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class NamedCurve
{
  public static final int sect163k1 = 1;
  public static final int sect163r1 = 2;
  public static final int sect163r2 = 3;
  public static final int sect193r1 = 4;
  public static final int sect193r2 = 5;
  public static final int sect233k1 = 6;
  public static final int sect233r1 = 7;
  public static final int sect239k1 = 8;
  public static final int sect283k1 = 9;
  public static final int sect283r1 = 10;
  public static final int sect409k1 = 11;
  public static final int sect409r1 = 12;
  public static final int sect571k1 = 13;
  public static final int sect571r1 = 14;
  public static final int secp160k1 = 15;
  public static final int secp160r1 = 16;
  public static final int secp160r2 = 17;
  public static final int secp192k1 = 18;
  public static final int secp192r1 = 19;
  public static final int secp224k1 = 20;
  public static final int secp224r1 = 21;
  public static final int secp256k1 = 22;
  public static final int secp256r1 = 23;
  public static final int secp384r1 = 24;
  public static final int secp521r1 = 25;
  public static final int arbitrary_explicit_prime_curves = 65281;
  public static final int arbitrary_explicit_char2_curves = 65282;
  
  public static boolean refersToASpecificNamedCurve(int paramInt)
  {
    switch (paramInt)
    {
    case 65281: 
    case 65282: 
      return false;
    }
    return true;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.NamedCurve
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class NewSessionTicket
{
  protected long ticketLifetimeHint;
  protected byte[] ticket;
  
  public NewSessionTicket(long paramLong, byte[] paramArrayOfByte)
  {
    ticketLifetimeHint = paramLong;
    ticket = paramArrayOfByte;
  }
  
  public long getTicketLifetimeHint()
  {
    return ticketLifetimeHint;
  }
  
  public byte[] getTicket()
  {
    return ticket;
  }
  
  public void encode(OutputStream paramOutputStream)
    throws IOException
  {
    TlsUtils.writeUint32(ticketLifetimeHint, paramOutputStream);
    TlsUtils.writeOpaque16(ticket, paramOutputStream);
  }
  
  public static NewSessionTicket parse(InputStream paramInputStream)
    throws IOException
  {
    long l = TlsUtils.readUint32(paramInputStream);
    byte[] arrayOfByte = TlsUtils.readOpaque16(paramInputStream);
    return new NewSessionTicket(l, arrayOfByte);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.NewSessionTicket
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class PRFAlgorithm
{
  public static final int tls_prf_legacy = 0;
  public static final int tls_prf_sha256 = 1;
  public static final int tls_prf_sha384 = 2;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.PRFAlgorithm
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;

public abstract class PSKTlsClient
  extends AbstractTlsClient
{
  protected TlsPSKIdentity pskIdentity;
  
  public PSKTlsClient(TlsPSKIdentity paramTlsPSKIdentity)
  {
    pskIdentity = paramTlsPSKIdentity;
  }
  
  public PSKTlsClient(TlsCipherFactory paramTlsCipherFactory, TlsPSKIdentity paramTlsPSKIdentity)
  {
    super(paramTlsCipherFactory);
    pskIdentity = paramTlsPSKIdentity;
  }
  
  public int[] getCipherSuites()
  {
    return new int[] { 145, 144, 143, 142, 149, 148, 147, 146, 141, 140, 139, 138 };
  }
  
  public TlsKeyExchange getKeyExchange()
    throws IOException
  {
    switch (selectedCipherSuite)
    {
    case 44: 
    case 138: 
    case 139: 
    case 140: 
    case 141: 
      return createPSKKeyExchange(13);
    case 46: 
    case 146: 
    case 147: 
    case 148: 
    case 149: 
      return createPSKKeyExchange(15);
    case 45: 
    case 142: 
    case 143: 
    case 144: 
    case 145: 
      return createPSKKeyExchange(14);
    }
    throw new TlsFatalAlert((short)80);
  }
  
  public TlsCipher getCipher()
    throws IOException
  {
    switch (selectedCipherSuite)
    {
    case 139: 
    case 143: 
    case 147: 
      return cipherFactory.createCipher(context, 7, 2);
    case 140: 
    case 144: 
    case 148: 
      return cipherFactory.createCipher(context, 8, 2);
    case 141: 
    case 145: 
    case 149: 
      return cipherFactory.createCipher(context, 9, 2);
    case 44: 
    case 45: 
    case 46: 
      return cipherFactory.createCipher(context, 0, 2);
    case 138: 
    case 142: 
    case 146: 
      return cipherFactory.createCipher(context, 2, 2);
    }
    throw new TlsFatalAlert((short)80);
  }
  
  protected TlsKeyExchange createPSKKeyExchange(int paramInt)
  {
    return new TlsPSKKeyExchange(paramInt, supportedSignatureAlgorithms, pskIdentity);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.PSKTlsClient
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;

public final class ProtocolVersion
{
  public static final ProtocolVersion SSLv3 = new ProtocolVersion(768, "SSL 3.0");
  public static final ProtocolVersion TLSv10 = new ProtocolVersion(769, "TLS 1.0");
  public static final ProtocolVersion TLSv11 = new ProtocolVersion(770, "TLS 1.1");
  public static final ProtocolVersion TLSv12 = new ProtocolVersion(771, "TLS 1.2");
  public static final ProtocolVersion DTLSv10 = new ProtocolVersion(65279, "DTLS 1.0");
  public static final ProtocolVersion DTLSv12 = new ProtocolVersion(65277, "DTLS 1.2");
  private int version;
  private String name;
  
  private ProtocolVersion(int paramInt, String paramString)
  {
    version = (paramInt & 0xFFFF);
    name = paramString;
  }
  
  public int getFullVersion()
  {
    return version;
  }
  
  public int getMajorVersion()
  {
    return version >> 8;
  }
  
  public int getMinorVersion()
  {
    return version & 0xFF;
  }
  
  public boolean isDTLS()
  {
    return getMajorVersion() == 254;
  }
  
  public boolean isSSL()
  {
    return this == SSLv3;
  }
  
  public ProtocolVersion getEquivalentTLSVersion()
  {
    if (!isDTLS()) {
      return this;
    }
    if (this == DTLSv10) {
      return TLSv11;
    }
    return TLSv12;
  }
  
  public boolean isEqualOrEarlierVersionOf(ProtocolVersion paramProtocolVersion)
  {
    if (getMajorVersion() != paramProtocolVersion.getMajorVersion()) {
      return false;
    }
    int i = paramProtocolVersion.getMinorVersion() - getMinorVersion();
    return i <= 0;
  }
  
  public boolean isLaterVersionOf(ProtocolVersion paramProtocolVersion)
  {
    if (getMajorVersion() != paramProtocolVersion.getMajorVersion()) {
      return false;
    }
    int i = paramProtocolVersion.getMinorVersion() - getMinorVersion();
    return i > 0;
  }
  
  public boolean equals(Object paramObject)
  {
    return this == paramObject;
  }
  
  public int hashCode()
  {
    return version;
  }
  
  public static ProtocolVersion get(int paramInt1, int paramInt2)
    throws IOException
  {
    switch (paramInt1)
    {
    case 3: 
      switch (paramInt2)
      {
      case 0: 
        return SSLv3;
      case 1: 
        return TLSv10;
      case 2: 
        return TLSv11;
      case 3: 
        return TLSv12;
      }
    case 254: 
      switch (paramInt2)
      {
      case 255: 
        return DTLSv10;
      case 253: 
        return DTLSv12;
      }
      break;
    }
    throw new TlsFatalAlert((short)47);
  }
  
  public String toString()
  {
    return name;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.ProtocolVersion
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.bouncycastle.crypto.Digest;

class RecordStream
{
  private static int PLAINTEXT_LIMIT = 16384;
  private static int COMPRESSED_LIMIT = PLAINTEXT_LIMIT + 1024;
  private static int CIPHERTEXT_LIMIT = COMPRESSED_LIMIT + 1024;
  private TlsProtocol handler;
  private InputStream input;
  private OutputStream output;
  private TlsCompression pendingCompression = null;
  private TlsCompression readCompression = null;
  private TlsCompression writeCompression = null;
  private TlsCipher pendingCipher = null;
  private TlsCipher readCipher = null;
  private TlsCipher writeCipher = null;
  private long readSeqNo = 0L;
  private long writeSeqNo = 0L;
  private ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  private TlsContext context = null;
  private TlsHandshakeHash hash = null;
  private ProtocolVersion readVersion = null;
  private ProtocolVersion writeVersion = null;
  private boolean restrictReadVersion = true;
  
  RecordStream(TlsProtocol paramTlsProtocol, InputStream paramInputStream, OutputStream paramOutputStream)
  {
    handler = paramTlsProtocol;
    input = paramInputStream;
    output = paramOutputStream;
    readCompression = new TlsNullCompression();
    writeCompression = readCompression;
    readCipher = new TlsNullCipher(context);
    writeCipher = readCipher;
  }
  
  void init(TlsContext paramTlsContext)
  {
    context = paramTlsContext;
    hash = new DeferredHash();
    hash.init(paramTlsContext);
  }
  
  ProtocolVersion getReadVersion()
  {
    return readVersion;
  }
  
  void setReadVersion(ProtocolVersion paramProtocolVersion)
  {
    readVersion = paramProtocolVersion;
  }
  
  void setWriteVersion(ProtocolVersion paramProtocolVersion)
  {
    writeVersion = paramProtocolVersion;
  }
  
  void setRestrictReadVersion(boolean paramBoolean)
  {
    restrictReadVersion = paramBoolean;
  }
  
  void notifyHelloComplete()
  {
    hash = hash.commit();
  }
  
  void setPendingConnectionState(TlsCompression paramTlsCompression, TlsCipher paramTlsCipher)
  {
    pendingCompression = paramTlsCompression;
    pendingCipher = paramTlsCipher;
  }
  
  void sentWriteCipherSpec()
    throws IOException
  {
    if ((pendingCompression == null) || (pendingCipher == null)) {
      throw new TlsFatalAlert((short)40);
    }
    writeCompression = pendingCompression;
    writeCipher = pendingCipher;
    writeSeqNo = 0L;
  }
  
  void receivedReadCipherSpec()
    throws IOException
  {
    if ((pendingCompression == null) || (pendingCipher == null)) {
      throw new TlsFatalAlert((short)40);
    }
    readCompression = pendingCompression;
    readCipher = pendingCipher;
    readSeqNo = 0L;
  }
  
  void finaliseHandshake()
    throws IOException
  {
    if ((readCompression != pendingCompression) || (writeCompression != pendingCompression) || (readCipher != pendingCipher) || (writeCipher != pendingCipher)) {
      throw new TlsFatalAlert((short)40);
    }
    pendingCompression = null;
    pendingCipher = null;
  }
  
  public void readRecord()
    throws IOException
  {
    short s = TlsUtils.readUint8(input);
    checkType(s, (short)10);
    if (!restrictReadVersion)
    {
      int i = TlsUtils.readVersionRaw(input);
      if ((i & 0xFF00) != 768) {
        throw new TlsFatalAlert((short)47);
      }
    }
    else
    {
      ProtocolVersion localProtocolVersion = TlsUtils.readVersion(input);
      if (readVersion == null) {
        readVersion = localProtocolVersion;
      } else if (!localProtocolVersion.equals(readVersion)) {
        throw new TlsFatalAlert((short)47);
      }
    }
    int j = TlsUtils.readUint16(input);
    byte[] arrayOfByte = decodeAndVerify(s, input, j);
    handler.processRecord(s, arrayOfByte, 0, arrayOfByte.length);
  }
  
  protected byte[] decodeAndVerify(short paramShort, InputStream paramInputStream, int paramInt)
    throws IOException
  {
    checkLength(paramInt, CIPHERTEXT_LIMIT, (short)22);
    byte[] arrayOfByte1 = TlsUtils.readFully(paramInt, paramInputStream);
    byte[] arrayOfByte2 = readCipher.decodeCiphertext(readSeqNo++, paramShort, arrayOfByte1, 0, arrayOfByte1.length);
    checkLength(arrayOfByte2.length, COMPRESSED_LIMIT, (short)22);
    OutputStream localOutputStream = readCompression.decompress(buffer);
    if (localOutputStream != buffer)
    {
      localOutputStream.write(arrayOfByte2, 0, arrayOfByte2.length);
      localOutputStream.flush();
      arrayOfByte2 = getBufferContents();
    }
    checkLength(arrayOfByte2.length, PLAINTEXT_LIMIT, (short)30);
    return arrayOfByte2;
  }
  
  protected void writeRecord(short paramShort, byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    checkType(paramShort, (short)80);
    checkLength(paramInt2, PLAINTEXT_LIMIT, (short)80);
    if ((paramInt2 < 1) && (paramShort != 23)) {
      throw new TlsFatalAlert((short)80);
    }
    if (paramShort == 22) {
      updateHandshakeData(paramArrayOfByte, paramInt1, paramInt2);
    }
    OutputStream localOutputStream = writeCompression.compress(buffer);
    byte[] arrayOfByte1;
    if (localOutputStream == buffer)
    {
      arrayOfByte1 = writeCipher.encodePlaintext(writeSeqNo++, paramShort, paramArrayOfByte, paramInt1, paramInt2);
    }
    else
    {
      localOutputStream.write(paramArrayOfByte, paramInt1, paramInt2);
      localOutputStream.flush();
      arrayOfByte2 = getBufferContents();
      checkLength(arrayOfByte2.length, paramInt2 + 1024, (short)80);
      arrayOfByte1 = writeCipher.encodePlaintext(writeSeqNo++, paramShort, arrayOfByte2, 0, arrayOfByte2.length);
    }
    checkLength(arrayOfByte1.length, CIPHERTEXT_LIMIT, (short)80);
    byte[] arrayOfByte2 = new byte[arrayOfByte1.length + 5];
    TlsUtils.writeUint8(paramShort, arrayOfByte2, 0);
    TlsUtils.writeVersion(writeVersion, arrayOfByte2, 1);
    TlsUtils.writeUint16(arrayOfByte1.length, arrayOfByte2, 3);
    System.arraycopy(arrayOfByte1, 0, arrayOfByte2, 5, arrayOfByte1.length);
    output.write(arrayOfByte2);
    output.flush();
  }
  
  void updateHandshakeData(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    hash.update(paramArrayOfByte, paramInt1, paramInt2);
  }
  
  byte[] getCurrentHash(byte[] paramArrayOfByte)
  {
    TlsHandshakeHash localTlsHandshakeHash = hash.fork();
    if ((context.getServerVersion().isSSL()) && (paramArrayOfByte != null)) {
      localTlsHandshakeHash.update(paramArrayOfByte, 0, paramArrayOfByte.length);
    }
    return doFinal(localTlsHandshakeHash);
  }
  
  protected void close()
    throws IOException
  {
    Object localObject = null;
    try
    {
      input.close();
    }
    catch (IOException localIOException1)
    {
      localObject = localIOException1;
    }
    try
    {
      output.close();
    }
    catch (IOException localIOException2)
    {
      localObject = localIOException2;
    }
    if (localObject != null) {
      throw ((Throwable)localObject);
    }
  }
  
  protected void flush()
    throws IOException
  {
    output.flush();
  }
  
  private byte[] getBufferContents()
  {
    byte[] arrayOfByte = buffer.toByteArray();
    buffer.reset();
    return arrayOfByte;
  }
  
  private static byte[] doFinal(Digest paramDigest)
  {
    byte[] arrayOfByte = new byte[paramDigest.getDigestSize()];
    paramDigest.doFinal(arrayOfByte, 0);
    return arrayOfByte;
  }
  
  private static void checkType(short paramShort1, short paramShort2)
    throws IOException
  {
    switch (paramShort1)
    {
    case 20: 
    case 21: 
    case 22: 
    case 23: 
      break;
    default: 
      throw new TlsFatalAlert(paramShort2);
    }
  }
  
  private static void checkLength(int paramInt1, int paramInt2, short paramShort)
    throws IOException
  {
    if (paramInt1 > paramInt2) {
      throw new TlsFatalAlert(paramShort);
    }
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.RecordStream
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Hashtable;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.util.Integers;

public abstract class SRPTlsClient
  extends AbstractTlsClient
{
  public static final Integer EXT_SRP = Integers.valueOf(12);
  protected byte[] identity;
  protected byte[] password;
  
  public SRPTlsClient(byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
  {
    identity = Arrays.clone(paramArrayOfByte1);
    password = Arrays.clone(paramArrayOfByte2);
  }
  
  public SRPTlsClient(TlsCipherFactory paramTlsCipherFactory, byte[] paramArrayOfByte1, byte[] paramArrayOfByte2)
  {
    super(paramTlsCipherFactory);
    identity = Arrays.clone(paramArrayOfByte1);
    password = Arrays.clone(paramArrayOfByte2);
  }
  
  public int[] getCipherSuites()
  {
    return new int[] { 49185, 49182, 49179, 49184, 49181, 49178 };
  }
  
  public Hashtable getClientExtensions()
    throws IOException
  {
    Hashtable localHashtable = super.getClientExtensions();
    if (localHashtable == null) {
      localHashtable = new Hashtable();
    }
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    TlsUtils.writeOpaque8(identity, localByteArrayOutputStream);
    localHashtable.put(EXT_SRP, localByteArrayOutputStream.toByteArray());
    return localHashtable;
  }
  
  public void processServerExtensions(Hashtable paramHashtable)
    throws IOException
  {
    if (paramHashtable != null)
    {
      byte[] arrayOfByte = (byte[])paramHashtable.get(EXT_SRP);
      if ((arrayOfByte != null) && (arrayOfByte.length > 0)) {
        throw new TlsFatalAlert((short)47);
      }
    }
  }
  
  public TlsKeyExchange getKeyExchange()
    throws IOException
  {
    switch (selectedCipherSuite)
    {
    case 49178: 
    case 49181: 
    case 49184: 
      return createSRPKeyExchange(21);
    case 49179: 
    case 49182: 
    case 49185: 
      return createSRPKeyExchange(23);
    case 49180: 
    case 49183: 
    case 49186: 
      return createSRPKeyExchange(22);
    }
    throw new TlsFatalAlert((short)80);
  }
  
  public TlsCipher getCipher()
    throws IOException
  {
    switch (selectedCipherSuite)
    {
    case 49178: 
    case 49179: 
    case 49180: 
      return cipherFactory.createCipher(context, 7, 2);
    case 49181: 
    case 49182: 
    case 49183: 
      return cipherFactory.createCipher(context, 8, 2);
    case 49184: 
    case 49185: 
    case 49186: 
      return cipherFactory.createCipher(context, 9, 2);
    }
    throw new TlsFatalAlert((short)80);
  }
  
  protected TlsKeyExchange createSRPKeyExchange(int paramInt)
  {
    return new TlsSRPKeyExchange(paramInt, supportedSignatureAlgorithms, identity, password);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SRPTlsClient
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class SRTPProtectionProfile
{
  public static final int SRTP_AES128_CM_HMAC_SHA1_80 = 1;
  public static final int SRTP_AES128_CM_HMAC_SHA1_32 = 2;
  public static final int SRTP_NULL_HMAC_SHA1_80 = 5;
  public static final int SRTP_NULL_HMAC_SHA1_32 = 6;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SRTPProtectionProfile
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import org.bouncycastle.crypto.CipherParameters;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.Mac;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.util.Arrays;

public class SSL3Mac
  implements Mac
{
  private static final byte IPAD_BYTE = 54;
  private static final byte OPAD_BYTE = 92;
  static final byte[] IPAD = genPad(, 48);
  static final byte[] OPAD = genPad((byte)92, 48);
  private Digest digest;
  private byte[] secret;
  private int padLength;
  
  public SSL3Mac(Digest paramDigest)
  {
    digest = paramDigest;
    if (paramDigest.getDigestSize() == 20) {
      padLength = 40;
    } else {
      padLength = 48;
    }
  }
  
  public String getAlgorithmName()
  {
    return digest.getAlgorithmName() + "/SSL3MAC";
  }
  
  public Digest getUnderlyingDigest()
  {
    return digest;
  }
  
  public void init(CipherParameters paramCipherParameters)
  {
    secret = Arrays.clone(((KeyParameter)paramCipherParameters).getKey());
    reset();
  }
  
  public int getMacSize()
  {
    return digest.getDigestSize();
  }
  
  public void update(byte paramByte)
  {
    digest.update(paramByte);
  }
  
  public void update(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    digest.update(paramArrayOfByte, paramInt1, paramInt2);
  }
  
  public int doFinal(byte[] paramArrayOfByte, int paramInt)
  {
    byte[] arrayOfByte = new byte[digest.getDigestSize()];
    digest.doFinal(arrayOfByte, 0);
    digest.update(secret, 0, secret.length);
    digest.update(OPAD, 0, padLength);
    digest.update(arrayOfByte, 0, arrayOfByte.length);
    int i = digest.doFinal(paramArrayOfByte, paramInt);
    reset();
    return i;
  }
  
  public void reset()
  {
    digest.reset();
    digest.update(secret, 0, secret.length);
    digest.update(IPAD, 0, padLength);
  }
  
  private static byte[] genPad(byte paramByte, int paramInt)
  {
    byte[] arrayOfByte = new byte[paramInt];
    Arrays.fill(arrayOfByte, paramByte);
    return arrayOfByte;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SSL3Mac
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class SecurityParameters
{
  int entity = -1;
  int prfAlgorithm = -1;
  short compressionAlgorithm = -1;
  int verifyDataLength = -1;
  byte[] masterSecret = null;
  byte[] clientRandom = null;
  byte[] serverRandom = null;
  
  public int getEntity()
  {
    return entity;
  }
  
  public int getPrfAlgorithm()
  {
    return prfAlgorithm;
  }
  
  public short getCompressionAlgorithm()
  {
    return compressionAlgorithm;
  }
  
  public int getVerifyDataLength()
  {
    return verifyDataLength;
  }
  
  public byte[] getMasterSecret()
  {
    return masterSecret;
  }
  
  public byte[] getClientRandom()
  {
    return clientRandom;
  }
  
  public byte[] getServerRandom()
  {
    return serverRandom;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SecurityParameters
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public abstract class ServerOnlyTlsAuthentication
  implements TlsAuthentication
{
  public final TlsCredentials getClientCredentials(CertificateRequest paramCertificateRequest)
  {
    return null;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.ServerOnlyTlsAuthentication
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class SignatureAlgorithm
{
  public static final short anonymous = 0;
  public static final short rsa = 1;
  public static final short dsa = 2;
  public static final short ecdsa = 3;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SignatureAlgorithm
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

public class SignatureAndHashAlgorithm
{
  private short hash;
  private short signature;
  
  public SignatureAndHashAlgorithm(short paramShort1, short paramShort2)
  {
    if (!TlsUtils.isValidUint8(paramShort1)) {
      throw new IllegalArgumentException("'hash' should be a uint8");
    }
    if (!TlsUtils.isValidUint8(paramShort2)) {
      throw new IllegalArgumentException("'signature' should be a uint8");
    }
    if (paramShort2 == 0) {
      throw new IllegalArgumentException("'signature' MUST NOT be \"anonymous\"");
    }
    hash = paramShort1;
    signature = paramShort2;
  }
  
  public short getHash()
  {
    return hash;
  }
  
  public short getSignature()
  {
    return signature;
  }
  
  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof SignatureAndHashAlgorithm)) {
      return false;
    }
    SignatureAndHashAlgorithm localSignatureAndHashAlgorithm = (SignatureAndHashAlgorithm)paramObject;
    return (localSignatureAndHashAlgorithm.getHash() == getHash()) && (localSignatureAndHashAlgorithm.getSignature() == getSignature());
  }
  
  public int hashCode()
  {
    return getHash() << 8 | getSignature();
  }
  
  public void encode(OutputStream paramOutputStream)
    throws IOException
  {
    TlsUtils.writeUint8(hash, paramOutputStream);
    TlsUtils.writeUint8(signature, paramOutputStream);
  }
  
  public static SignatureAndHashAlgorithm parse(InputStream paramInputStream)
    throws IOException
  {
    short s1 = TlsUtils.readUint8(paramInputStream);
    short s2 = TlsUtils.readUint8(paramInputStream);
    return new SignatureAndHashAlgorithm(s1, s2);
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SignatureAndHashAlgorithm
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class SupplementalDataEntry
{
  private int supp_data_type;
  private byte[] data;
  
  public SupplementalDataEntry(int paramInt, byte[] paramArrayOfByte)
  {
    supp_data_type = paramInt;
    data = paramArrayOfByte;
  }
  
  public int getDataType()
  {
    return supp_data_type;
  }
  
  public byte[] getData()
  {
    return data;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SupplementalDataEntry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

public class SupplementalDataType
{
  public static final int user_mapping_data = 0;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.SupplementalDataType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;
import org.bouncycastle.crypto.modes.AEADBlockCipher;
import org.bouncycastle.crypto.params.AEADParameters;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.util.Arrays;

public class TlsAEADCipher
  implements TlsCipher
{
  protected TlsContext context;
  protected int macSize;
  protected int nonce_explicit_length;
  protected AEADBlockCipher encryptCipher;
  protected AEADBlockCipher decryptCipher;
  protected byte[] encryptImplicitNonce;
  protected byte[] decryptImplicitNonce;
  
  public TlsAEADCipher(TlsContext paramTlsContext, AEADBlockCipher paramAEADBlockCipher1, AEADBlockCipher paramAEADBlockCipher2, int paramInt1, int paramInt2)
    throws IOException
  {
    if (!ProtocolVersion.TLSv12.isEqualOrEarlierVersionOf(paramTlsContext.getServerVersion().getEquivalentTLSVersion())) {
      throw new TlsFatalAlert((short)80);
    }
    context = paramTlsContext;
    macSize = paramInt2;
    nonce_explicit_length = 8;
    int i = 4;
    int j = 2 * paramInt1 + 2 * i;
    byte[] arrayOfByte1 = TlsUtils.calculateKeyBlock(paramTlsContext, j);
    int k = 0;
    KeyParameter localKeyParameter1 = new KeyParameter(arrayOfByte1, k, paramInt1);
    k += paramInt1;
    KeyParameter localKeyParameter2 = new KeyParameter(arrayOfByte1, k, paramInt1);
    k += paramInt1;
    byte[] arrayOfByte2 = Arrays.copyOfRange(arrayOfByte1, k, k + i);
    k += i;
    byte[] arrayOfByte3 = Arrays.copyOfRange(arrayOfByte1, k, k + i);
    k += i;
    if (k != j) {
      throw new TlsFatalAlert((short)80);
    }
    KeyParameter localKeyParameter3;
    KeyParameter localKeyParameter4;
    if (paramTlsContext.isServer())
    {
      encryptCipher = paramAEADBlockCipher2;
      decryptCipher = paramAEADBlockCipher1;
      encryptImplicitNonce = arrayOfByte3;
      decryptImplicitNonce = arrayOfByte2;
      localKeyParameter3 = localKeyParameter2;
      localKeyParameter4 = localKeyParameter1;
    }
    else
    {
      encryptCipher = paramAEADBlockCipher1;
      decryptCipher = paramAEADBlockCipher2;
      encryptImplicitNonce = arrayOfByte2;
      decryptImplicitNonce = arrayOfByte3;
      localKeyParameter3 = localKeyParameter1;
      localKeyParameter4 = localKeyParameter2;
    }
    byte[] arrayOfByte4 = new byte[i + nonce_explicit_length];
    encryptCipher.init(true, new AEADParameters(localKeyParameter3, 8 * paramInt2, arrayOfByte4));
    decryptCipher.init(false, new AEADParameters(localKeyParameter4, 8 * paramInt2, arrayOfByte4));
  }
  
  public int getPlaintextLimit(int paramInt)
  {
    return paramInt - macSize - nonce_explicit_length;
  }
  
  public byte[] encodePlaintext(long paramLong, short paramShort, byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    byte[] arrayOfByte1 = new byte[encryptImplicitNonce.length + nonce_explicit_length];
    System.arraycopy(encryptImplicitNonce, 0, arrayOfByte1, 0, encryptImplicitNonce.length);
    TlsUtils.writeUint64(paramLong, arrayOfByte1, encryptImplicitNonce.length);
    int i = paramInt1;
    int j = paramInt2;
    int k = encryptCipher.getOutputSize(j);
    byte[] arrayOfByte2 = new byte[nonce_explicit_length + k];
    System.arraycopy(arrayOfByte1, encryptImplicitNonce.length, arrayOfByte2, 0, nonce_explicit_length);
    int m = nonce_explicit_length;
    encryptCipher.init(true, new AEADParameters(null, 8 * macSize, arrayOfByte1, getAdditionalData(paramLong, paramShort, j)));
    m += encryptCipher.processBytes(paramArrayOfByte, i, j, arrayOfByte2, m);
    try
    {
      m += encryptCipher.doFinal(arrayOfByte2, m);
    }
    catch (Exception localException)
    {
      throw new TlsFatalAlert((short)80);
    }
    if (m != arrayOfByte2.length) {
      throw new TlsFatalAlert((short)80);
    }
    return arrayOfByte2;
  }
  
  public byte[] decodeCiphertext(long paramLong, short paramShort, byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    if (getPlaintextLimit(paramInt2) < 0) {
      throw new TlsFatalAlert((short)50);
    }
    byte[] arrayOfByte1 = new byte[decryptImplicitNonce.length + nonce_explicit_length];
    System.arraycopy(decryptImplicitNonce, 0, arrayOfByte1, 0, decryptImplicitNonce.length);
    System.arraycopy(paramArrayOfByte, paramInt1, arrayOfByte1, decryptImplicitNonce.length, nonce_explicit_length);
    int i = paramInt1 + nonce_explicit_length;
    int j = paramInt2 - nonce_explicit_length;
    int k = decryptCipher.getOutputSize(j);
    byte[] arrayOfByte2 = new byte[k];
    int m = 0;
    decryptCipher.init(false, new AEADParameters(null, 8 * macSize, arrayOfByte1, getAdditionalData(paramLong, paramShort, k)));
    m += decryptCipher.processBytes(paramArrayOfByte, i, j, arrayOfByte2, m);
    try
    {
      m += decryptCipher.doFinal(arrayOfByte2, m);
    }
    catch (Exception localException)
    {
      throw new TlsFatalAlert((short)20);
    }
    if (m != arrayOfByte2.length) {
      throw new TlsFatalAlert((short)80);
    }
    return arrayOfByte2;
  }
  
  protected byte[] getAdditionalData(long paramLong, short paramShort, int paramInt)
    throws IOException
  {
    byte[] arrayOfByte = new byte[13];
    TlsUtils.writeUint64(paramLong, arrayOfByte, 0);
    TlsUtils.writeUint8(paramShort, arrayOfByte, 8);
    TlsUtils.writeVersion(context.getServerVersion(), arrayOfByte, 9);
    TlsUtils.writeUint16(paramInt, arrayOfByte, 11);
    return arrayOfByte;
  }
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.TlsAEADCipher
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;
import org.bouncycastle.crypto.params.AsymmetricKeyParameter;

public abstract interface TlsAgreementCredentials
  extends TlsCredentials
{
  public abstract byte[] generateAgreement(AsymmetricKeyParameter paramAsymmetricKeyParameter)
    throws IOException;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.TlsAgreementCredentials
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;

public abstract interface TlsAuthentication
{
  public abstract void notifyServerCertificate(Certificate paramCertificate)
    throws IOException;
  
  public abstract TlsCredentials getClientCredentials(CertificateRequest paramCertificateRequest)
    throws IOException;
}

/* Location:
 * Qualified Name:     org.bouncycastle.crypto.tls.TlsAuthentication
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.bouncycastle.crypto.tls;

import java.io.IOException;
import java.security.SecureRandom;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.Digest;
import org.bouncycastle.crypto.params.KeyParameter;
import org.bouncycastle.crypto.params.ParametersWithIV;
import org.bouncycastle.util.Arrays;

public class TlsBlockCipher
  implements TlsCipher
{
  protected TlsContext context;
  protected byte[] randomData;
  protected boolean useExplicitIV;
  protected BlockCipher encryptCipher;
  protected BlockCipher decryptCipher;
  protected TlsMac writeMac;
  protected TlsMac readMac;
  
  public TlsMac getWriteMac()
  {
    return writeMac;
  }
  
  public TlsMac getReadMac()
  {
    return readMac;
  }
  
  public TlsBlockCipher(TlsContext paramTlsContext, BlockCipher paramBlockCipher1, BlockCipher paramBlockCipher2, Digest paramDigest1, Digest paramDigest2, int paramInt)
    throws IOException
  {
    context = paramTlsContext;
    randomData = new byte['?'];
    paramTlsContext.getSecureRandom().nextBytes(randomData);
    useExplicitIV = ProtocolVersion.TLSv11.isEqualOrEarlierVersionOf(paramTlsContext.getServerVersion().getEquivalentTLSVersion());
    int i = 2 * paramInt + paramDigest1.getDigestSize() + paramDigest2.getDigestSize();
    if (!useExplicitIV) {
      i += paramBlockCipher1.getBlockSize() + paramBlockCipher2.getBlockSize();
    }
    byte[] arrayOfByte1 = TlsUtils.calculateKeyBlock(paramTlsContext, i);
    int j = 0;
    TlsMac localTlsMac1 = new TlsMac(paramTlsContext, paramDigest1, arrayOfByte1, j, paramDigest1.getDigestSize());
    j += paramDigest1.getDigestSize();
    TlsMac localTlsMac2 = new TlsMac(paramTlsContext, paramDigest2, arrayOfByte1, j, paramDigest2.getDigestSize());
    j += paramDigest2.getDigestSize();
    KeyParameter localKeyParameter1 = new KeyParameter(arrayOfByte1, j, paramInt);
    j += paramInt;
    KeyParameter localKeyParameter2 = new KeyParameter(arrayOfByte1, j, paramInt);
    j += paramInt;
    byte[] arrayOfByte2;
    byte[] arrayOfByte3;
    if (useExplicitIV)
    {
      arrayOfByte2 = new byte[paramBlockCipher1.getBlockSize()];
      arrayOfByte3 = new byte[paramBlockCipher2.getBlockSize()];
    }
    else
    {
      arrayOfByte2 = Arrays.copyOfRange(arrayOfByte1, j, j + paramBlockCipher1.getBlockSize());
      j += paramBlockCipher1.getBlockSize();
      arrayOfByte3 = Arrays.copyOfRange(arrayOfByte1, j, j + paramBlockCipher2.getBlockSize());
      j += paramBlockCipher2.getBlockSize();
    }
    if (j != i) {
      throw new TlsFatalAlert((short)80);
    }
    ParametersWithIV localParametersWithIV1;
    ParametersWithIV localParametersWithIV2;
    if (paramTlsContext.isServer())
    {
      writeMac = localTlsMac2;
      readMac = localTlsMac1;
      encryptCipher = paramBlockCipher2;
      decryptCipher = paramBlockCipher1;
      localParametersWithIV1 = new ParametersWithIV(localKeyParameter2, arrayOfByte3);
      localParametersWithIV2 = new ParametersWithIV(localKeyParameter1, arrayOfByte2);
    }
    else
    {
      writeMac = localTlsMac1;
      readMac = localTlsMac2;
      encryptCipher = paramBlockCipher1;
      decryptCipher = paramBlockCipher2;
      localParametersWithIV1 = new ParametersWithIV(localKeyParameter1, arrayOfByte2);
      localParametersWithIV2 = new ParametersWithIV(localKeyParameter2, arrayOfByte3);
    }
    encryptCipher.init(true, localParametersWithIV1);
    decryptCipher.init(false, localParametersWithIV2);
  }
  
  public int getPlaintextLimit(int paramInt)
  {
    int i = encryptCipher.getBlockSize();
    int j = writeMac.getSize();
    int k = paramInt - paramInt % i - j - 1;
    if (useExplicitIV) {
      k -= i;
    }
    return k;
  }
  
  public byte[] encodePlaintext(long paramLong, short paramShort, byte[] paramArrayOfByte, int paramInt1, int paramInt2)
  {
    int i = encryptCipher.getBlockSize();
    int j = writeMac.getSize();
    ProtocolVersion localProtocolVersion = context.getServerVersion();
    int k = i - 1 - (paramInt2 + j) % i;
    if ((!localProtocolVersion.isDTLS()) && (!localProtocolVersion.isSSL()))
    {
      m = (255 - k) / i;
      int n = chooseExtraPadBlocks(context.getSecureRandom(), m);
      k += n * i;
    }
    int m = pa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd