Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jsleuth
Visitor

PBKDF2

I am attempting to implement PBKDF2 (Password-Based Key Derivation Function 2) in britescript. I managed to implement a dynamic hashing function using roHMAC and roByteArray. The two steps I'm having trouble with are converting an ascii string to binary (and back) and also a bit-wise XOR function.

Any thoughts?
0 Kudos
2 REPLIES 2
TheEndless
Channel Surfer

Re: PBKDF2

roByteArray has both FromAsciiString and ToAsciiString methods.

For XOR, try this:
Function Xor(a As Integer, b As Integer) As Integer
If a = 0 Then Return b
If b = 0 Then Return a
Return ((a And Not b) Or (Not a And b))
End Function
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
jsleuth
Visitor

Re: PBKDF2

Excellent, thanks, that's what I went with.

I can't tell if there's a subtle bug in britescript or not but after adding the extra bytes to the end of the salt the ascii-based SHA256 hashing was producing incorrect values. When I switched to hexString-based hashing everything started to work though.

The other downside is that the recommended 4096 loops of hashing takes multiple minutes to complete on the roku box. I don't think it'll actually be usable in this case. Bummer. 😞
0 Kudos