java - Bouncy castle no such provider exception -


i have added bouncy castle jar file application class path in android , in java. code i've used in both of them. doesn't seem recognize provider "bc".

securerandom sr1=new securerandom().getinstance("sha1prng", "bc");       system.out.println(sr1.getprovider());       sr1.setseed(12);       byte[] a=new byte[0];       sr1.nextbytes(a);       int ai=a[0];       system.out.println(ai); 


throws following exception in both android , in java:

java.security.nosuchproviderexception: no such provider: bc 


how correct this?
had not added provider in policy file. after doing getting following exception.

java.security.nosuchalgorithmexception: no such algorithm: sha1prng provider  bc<br> 

does mean bouncy castle not provide implementation of "sha1prng" algorithm? whole reason imported bouncy castle have common provider in both android , in java, sequence of random numbers generated same seed same in both android , java.

apparently doesn't provide securerandom implementation @ all. can system implementation (from harmony) (no need create instance call static method):

securerandom.getinstance("sha1prng") 

bouncycastle has digestrandomgenerator used in similar manner, may or may not compatible sun sha1prng (which appears proprietary, , defined)

re: generating otps using securerandom: securerandom fixed seed not right tool this. generate otps, should use secret key combined predictable element (time or counter). standard way using hmac specified e.g. oath. read rfc 4226 details.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -