Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
214 views
in Technique[技术] by (71.8m points)

java - Change a library file from read-only to writable - Android Studio

I have a project where I have to add some security features to the signal application 's code that I have cloned from Github. I am working on Android Studio.

What I need to do for my work is to do some changes at the SessionCipher class which is a part of the library libsignal. The SessionCipher.java is a read-only file, so it doesn't let me do the necessary modification. Is there a way to change this file to writable?

Here is a piece of code that calls the SessionCipher class of the libsignal library.

import org.whispersystems.libsignal.SessionCipher;


  public OutgoingPushMessage encrypt(SignalProtocolAddress        destination,
                                     Optional<UnidentifiedAccess> unidentifiedAccess,
                                     byte[]                       unpaddedMessage)
          throws UntrustedIdentityException, InvalidKeyException
  {
   
      SessionCipher        sessionCipher        = new SessionCipher(signalProtocolStore, destination);
      PushTransportDetails transportDetails     = new PushTransportDetails(sessionCipher.getSessionVersion());
      CiphertextMessage    message1              = sessionCipher.encrypt(transportDetails.getPaddedMessageBody(unpaddedMessage));
      CiphertextMessage    message              = sessionCipher.encrypt(message1.serialize());
      int                  remoteRegistrationId = sessionCipher.getRemoteRegistrationId();
      String               body                 = Base64.encodeBytes(message.serialize());

      int type;

      switch (message.getType()) {
        case CiphertextMessage.PREKEY_TYPE:  type = Type.PREKEY_BUNDLE_VALUE; break;
        case CiphertextMessage.WHISPER_TYPE: type = Type.CIPHERTEXT_VALUE;    break;
        default: throw new AssertionError("Bad type: " + message.getType());
      }

      return new OutgoingPushMessage(type, destination.getDeviceId(), remoteRegistrationId, body);
    }
question from:https://stackoverflow.com/questions/65892652/change-a-library-file-from-read-only-to-writable-android-studio

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...