Skip to content

iambumblehead/titanium-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

The Titanium Core Files

OVERVIEW:

A collection of scripts for encryption/decryption.

Numerous authors produced the scripts included here:

A description of these files from one of its authors, Atsushi Oka:

This library is an object oriented cryptography toolkit that implements several fundamental cryptographic algorithms including TWOFISH, SERPENT, RIJNDAEL, RSA with key-generation and SHA(SHA-1,224,256,384,512) for JavaScript. This library works in ActionScript as well. The unique feature of this library is asynchronous processing. A heavyweight process such as 4096bit RSA key generation will be done asynchronously so that this library does not cause problems such as freezing browsers, "slow-downing" warning dialogs, etc.

The original RSA-related scripts authored by Tom Wu are not sufficient for browser scripting environments. Key generation involves one un-interruptable process.

Atsushi Oka's modified version of these scripts is better suited for browser environments. Additionally, his code is documented and simple to use. Unfortunately, his scripts augment host objects and they use an unfamiliar script-loading utility. I have modified his files to instead use a series of super constructors. These are primarily found in tools/NonStructureLib.js. I have only updated the RSA-related code to use these constructors.

Atsushi Oka's scripts require the additional code to allow usage of his Nested Closure Oriented Programming, a programming paradigm he invented for use with javascript.


Include the titanium-core scripts in your document. At present there are quite a few files and only some of the files are needed for certain tasks. It would be possible to spend time editing these files to remove some of the dependencies. Maybe I'll do it in the future.

<script src="/js/titanium-core/lib/tools/elapse.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/tools/packages.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/tools/isarray.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/BigInteger_init1.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/RSA_init1.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/BigInteger_init2.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/SecureRandom.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/RSA_init2.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/tools/binary.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/RSAMessageFormat.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/Cipher.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/SOAEP.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/RSAMessageFormatSOAEP.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/BitPadding.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/RSAMessageFormatBitPadding.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/RSAKeyFormat.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/tools/NonStructureLib.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/tools/nonstructured.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/BigInteger_init3.js" type="text/javascript"></script>
<script src="/js/titanium-core/lib/RSA_init3.js" type="text/javascript"></script>
<script src="/js/titanium-core/RSA_manager.js" type="text/javascript"></script>

And a simple example seems sufficient:

var success = 0, failure = 0;

(function test(x) {
   if (!x--) return null;
   RSA_manager.execute(1024, '3', function(){}, function (RSAObj) {
      // response is an RSA key object, given from _new RSA()_
      setTimeout(function () {
         var priKey = base64x_encode( RSAObj.privateKeyBytes() ),
         pubKey = base64x_encode( RSAObj.publicKeyBytes() ),
         cipher = RSA_manager.getPubKeyEncrypted(pubKey, 'test message');
         RSA_manager.getPriKeyDecryptedAsync(priKey, cipher, function (err, value) {
            if (value === 'test message') {
               console.log('success ' + ++success);
            } else {
               console.log('failure ' + ++failure);
            }
            test(x);
         });
      }, 2);
   });
}(3));

The RSA_manager code comes primarly from code that is taken directly from one of Atsushi Oka's demonstration pages, here and here. I've made very few changes to the code and much of it is not needed for the generation of keys, encryption, decryption etc. You are forewarned.

About

modified cryptography toolkit

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published