Exemplo n.º 1
0
  /**
   * Change the authorization protocol being used to receive messages on the connection. This
   * routine must be called when the RecvThread is synchronized with the Vat thread. This assertion
   * is checked by setting myChangeProtocolIsOk just before calling into the Vat with a new incoming
   * message and resetting it when the call returns. This routine will throw an Assertion failure if
   * that boolean is not true.
   *
   * @param protocolParms is the parameter bundle for the protocol suite to use. This routine must,
   *     of course, support the selected suite.
   */
  void changeProtocol(AuthSecrets protocolParms) {
    if (Trace.comm.verbose && Trace.ON) {
      Trace.comm.verbosem("ProtocolChange, pp=" + protocolParms);
    }
    T.require(
        myChangeProtocolIsOk,
        "Must only be called while caller " + "is processing an input message");
    // For calculating the header length
    int headerLengthIndex = HEADER_INVALID;

    if (StartUpProtocol.PROTO_NONE.equals(protocolParms.myProtocolSuite)) {
      myIsAggragating = false;
      myIsDoingMac = false;
      mySequence = null;
      headerLengthIndex = HEADER_INT_LENGTH;
      // begin daffE -> E
    } else if (StartUpProtocol.PROTO_3DES_SDH_M.equals(protocolParms.myProtocolSuite)) {
      myIsAggragating = true;
      MessageDigest md5 = setSHA1(protocolParms);
      headerLengthIndex = HEADER_VLEN_SHA1;
      mySequence = null;
      byte[] raw_3des_key = TripleDESKeyConstructor.make(protocolParms.myDHSecret);
      myTransform = new Decrypt3DES(raw_3des_key, protocolParms.myIncomingSequence);
      // end daffE -> E
      // begin improved E protocol
    } else if (StartUpProtocol.PROTO_3DES_SDH_M2.equals(protocolParms.myProtocolSuite)) {
      myIsAggragating = true;
      MessageDigest md5 = setSHA1(protocolParms);
      headerLengthIndex = HEADER_VLEN_HMAC;
      mySequence = new byte[4]; // Assume initialized to zero
      byte[] raw_3des_key = TripleDESKeyConstructor.make(protocolParms.myDHSecret);
      myTransform = new Decrypt3DES(raw_3des_key, protocolParms.myIncomingSequence);
      myTransform.init();
      myIsStandardCBC = true;
      myIsDoingHMAC = true;
      // end improved E protocol
    } else {
      T.fail("Invalid protocol type " + protocolParms);
    }
    myIsCompressingMsgLengths = myIsAggragating;

    int len = theHeaderLengths[headerLengthIndex];
    T.require(0 <= len, "Invalid header length code");
    myHeader = new byte[len];
  }
Exemplo n.º 2
0
 /** Matches a nullOk[x] guard made by this. */
 public Object match__get_1(Object specimen, OneArgFunc optEjector) {
   T.require(null == myOptSubGuard, "Already parameterized: ", this);
   ClassDesc kind = ClassDesc.make(NullOkGuard.class);
   NullOkGuard ofKind = (NullOkGuard) kind.coerce(specimen, optEjector);
   if (ofKind.myOptSubGuard == null) {
     throw Thrower.toEject(optEjector, "Not a parameterized nullOk");
   }
   Object[] result = {ofKind.myOptSubGuard};
   return ConstList.fromArray(result);
 }
Exemplo n.º 3
0
 Purse(BigInteger balance) {
   T.require(0 <= balance.signum(), "oops");
   myBalance = balance;
   myDecr = new Decr();
 }
Exemplo n.º 4
0
 /**
  * Makes a Guard that accepts either null or values that the argument 'subGuard' accepts.
  *
  * <p>Non-null values are coerced by the argument.
  */
 public NullOkGuard get(Guard subGuard) {
   T.require(null == myOptSubGuard, "can only combine with one Guard");
   T.notNull(subGuard, "Missing sub-guard parameter");
   return new NullOkGuard(subGuard);
 }
Exemplo n.º 5
0
 public void decr(BigInteger amount) {
   T.require(0 <= amount.signum() && 0 >= amount.compareTo(myBalance), "oops");
   myBalance = myBalance.subtract(amount);
 }