   'bluebird'
 ], (require) ->
 
-  Forge        = require 'forge'
-  Logger       = require 'kryptnostic.logger'
-  Promise      = require 'bluebird'
+  Forge            = require 'forge'
+  Logger           = require 'kryptnostic.logger'
+  Promise          = require 'bluebird'
   
-  log          = Logger.get('RsaKeyGenerator')
+  log              = Logger.get('RsaKeyGenerator')
   
-  RSA_KEY_SIZE = 4096
-  EXPONENT     = 0x10001
+  RSA_KEY_SIZE     = 4096
+  EXPONENT_NUM     = 0x10001
+  EXPONENT_BIG_INT = new Uint8Array([1, 0, 1])
 
   class RsaKeyGenerator
-
-    
-    generate: (params) ->
-      if window.crypto?.subtle?
-        return @webCryptoGenerate(params)
-      else if window.msCrypto?.subtle?
-        return @ieWebCryptoGenerate(params)
-      else
-        return @forgeGenerate(params)
 
     forgeGenerate: (params) ->
       Promise.resolve()

        window.crypto.subtle.generateKey( {
          name: 'RSA-OAEP'
          modulusLength: params.bits
          publicExponent: new Uint8Array([1, 0, 1]) # constants
          hash: { name: 'SHA-256' }
        }, true, ['encrypt', 'decrypt'])
      .then (keys) ->

        keyOperation = window.msCrypto.subtle.generateKey( {
          name: 'RSA-OAEP'
          modulusLength: params.bits
          publicExponent: params.e
          hash: { name: 'SHA-256' }
        }, true, ['encrypt', 'decrypt'])
        keyOperation.onerror = ->
          log.error('Failed to generate RSA keys using IE web crypto')

        keyOperation.oncomplete = ->
          keyPair = keyOperation.result
          return deferred.resolve(keyPair)
        
        return deferred.promise
