Comments (10)
Hi.
Thanks for issue submitting.
I will investigate this as soon as possible.
Regards.
from binaryprefs.
@balamyt I see that you has no have default constructor for MyEntity
class. You actually don't?
from binaryprefs.
Also your customEncryptor#encrypt
or recrypt
field's methods implementation returns correct encrypted result or byte[0]
?
from binaryprefs.
This usually happens if you provide empty byte array into FileAdapter
for saving.
from binaryprefs.
Also try to use no-op encryption to replay the situation: https://github.com/iamironz/binaryprefs/blob/master/library/src/main/java/com/ironz/binaryprefs/encryption/ByteEncryption.java#L27-L37
from binaryprefs.
I see that you has no have default constructor for MyEntity class. You actually don't?
Yes, I have not default constructor.
my customEncryptor#encrypt
:
@Override
public byte[] encrypt(byte[] bytes) {
if (!hasAlias()) {
throw createExceptionForDevelopment("set aliases to keystore before encrypt");
}
try {
KeyStore.PrivateKeyEntry privateKeyEntry = (KeyStore.PrivateKeyEntry) mKeyStore.getEntry(mAlias, null);
RSAPublicKey publicKey = (RSAPublicKey) privateKeyEntry.getCertificate().getPublicKey();
Cipher inCipher = Cipher.getInstance("RSA/ECB/PKCS1Padding", "AndroidOpenSSL");
inCipher.init(Cipher.ENCRYPT_MODE, publicKey);
return encrypt(bytes, inCipher);
} catch (NoSuchAlgorithmException | UnrecoverableEntryException | KeyStoreException | NoSuchProviderException e) {
throw createExceptionForUser("in encrypt() something wrong at process with encryption", e, e.getLocalizedMessage());
} catch (NoSuchPaddingException | InvalidKeyException e) {
throw createExceptionForDevelopment("need check to correct alias before");
}
}
private byte[] encrypt(byte[] bytes, Cipher inCipher) throws AppKeystoreException {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
CipherOutputStream cipherOutputStream = new CipherOutputStream(outputStream, inCipher);
try {
cipherOutputStream.write(bytes);
return outputStream.toByteArray();
} catch (IOException e) {
throw createExceptionForUser("in encrypt() something wrong at process with cipherOutputStream", e, e.getLocalizedMessage());
} finally {
CloseableUtils.close(cipherOutputStream);
}
}
from binaryprefs.
@balamyt try create an unit test which encrypts and decrypts non-empty byte[]
value with your encryption.
from binaryprefs.
Also please note that you should have default constructor because during initialization it will be called.
from binaryprefs.
Thank!!
It's all right!
The problem was my encryption implementation.
from binaryprefs.
Also i've added two stages byte array length checking:
iamironz@bf0ef9d
iamironz@53678f7
This checks will be in 1.0.0-ALPHA1 release.
Regards.
from binaryprefs.
Related Issues (20)
- Problem with getting data from Set<String> HOT 5
- Incorrect state of contains method of BinaryPrefs after creation HOT 4
- editor.clear() not clears prefs HOT 4
- Add lazy evaluation for default values HOT 4
- Impossible to use without Android HOT 1
- FileChannel#write is now removed from 28 dp1 api
- How to make changes in Persistable class HOT 5
- External storage sometimes is empty line
- Preferences should be instantiated in the main thread. HOT 8
- Encryption key update HOT 4
- Support for Lists, Sets and Arrays HOT 4
- RuntimeException: Unable to start receiver com.ironz.binaryprefs.dump.DumpReceiver HOT 3
- Can't create preferences directory in /mnt/expand/ HOT 1
- So the inter process part is asynchronized? HOT 1
- Change UnsupportedClassVersionError error to an meaningful
- In-memory cache of byte array is vulnerable for external modifications HOT 3
- 🐞Bug with encryption HOT 3
- Create a ktx module
- Could you release the new version with current changes please? HOT 5
- Clear all prefs at once
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binaryprefs.