arlolra / otr

Off-the-Record Messaging Protocol implemented in JavaScript
https://arlolra.github.io/otr/
Mozilla Public License 2.0
458 stars 61 forks source link

Is Posible to Use OTR in Titanium appcelerator? #52

Closed skmohanraj closed 10 years ago

skmohanraj commented 10 years ago

I'm trying to create a chat application using Titanium appcelerator for iOS. For that i have implemented OTR.JS in my node js application. That works fine, But now i want to implement OTR.JS in Titanium Appcelator.

I searching modules in Titanium Appcelator to implement OTR for my application. But I can't found any solution for this.

So can anyone clarify me, To use OTR.JS in my Titanium Appcelator Application. If there is any example, please suggest me.

arlolra commented 10 years ago

Hi @skmohanraj,

Unfortunately, I'm not too familiar with Titanium Appcelator and don't have any examples readily available. However, it should be possible to use OTR.js in your application.

As an alternative, you can give titanium_otr a try. /cc @mnaamani

skmohanraj commented 10 years ago

thats @mnaamani only for android, i wanna source to ios aloy application. Any way Thanks for Ur Reply...

arlolra commented 10 years ago

Might OTRKit be useful?

imprabhu commented 10 years ago

I also tried these module with the Titanium Appcelator (iOS), I made changes to this module, But still not succeed. I think it's because in the following code in the bitint.js file

var randomBytes = (function () { // in node if ( typeof crypto !== 'undefined' && typeof crypto.randomBytes === 'function' ) { return function (n) { try { var buf = crypto.randomBytes(n) } catch (e) { throw e } return Array.prototype.slice.call(buf, 0) } } // in browser else if ( typeof crypto !== 'undefined' && typeof crypto.getRandomValues === 'function' ) { return function (n) { var buf = new Uint8Array(n) crypto.getRandomValues(buf) return Array.prototype.slice.call(buf, 0) } } // err else { throw new Error('Keys should not be generated without CSPRNG.') mystery bugs } }())

when i run the project it shows "'Keys should not be generated without CSPRNG" error.

I think the module only supports for browser and node js. I don't know whether this module suits for Titanium Appcelerator.

Please provide suggestion to make it to run on Titanium mobile iOS.

mnaamani commented 10 years ago

OTRKit suggested by @arlolra is the first step. A titanium module would then have to be developed which wraps it and exposes a javascript API for titanium applications. https://wiki.appcelerator.org/display/guides2/iOS+Module+Development+Guide

Alternatively I could suggest to try and use OTR.js and creating titanium modules just for the missing 'node' components such as the CSPRNG for example.

skmohanraj commented 10 years ago

HI Thanks for ur reply, i upload my titanium project in google drive https://drive.google.com/file/d/0B0dC9rg5ONlvRFNKU2RUNjFIU3c/edit?usp=sharing

I have made changes the modules from arlolraOTR In this project simply i need if i click the "testOtr Button" encrypt a text "haii" shows an Encrypt text as well as Decrypt. when u click the button the key will be genrated at first time so it wwill take some minutes. On that genrated key i used math.random(). but arlolra/otr using CSPRNG. Currently shows the error

"'undefined' is not an object (evaluating 'self[this.meth].bind')"; on 'otr/lib/ake.js'

Actually i don't know is this a correct way to encrypt a text adapt from arlolra/otr. do u have any suggestion?

arlolra commented 10 years ago

@skmohanraj Please see my response here.