Privacy/Features/DOMCryptAPISpec/Latest: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 59: Line 59:




== Browser Window property ==
== Browser Window property WebIDL ==


;window.mozCrypto<br>
;window.mozCrypto<br>
Line 65: Line 65:
All windows will have this property (in the current implementation) for the time being as this API is hashed out.
All windows will have this property (in the current implementation) for the time being as this API is hashed out.


The property is namespaced in order to provide future capabilities. The current design is asynchronous and looks like this: <br>  
The property is namespaced in order to provide future capabilities.<br>  


<pre class="brush:js;toolbar:false;">  
<pre class="brush:js;toolbar:false;">  
{  
[Supplemental]
  pk: {
interface Crypto {
    // Public Key API
  readonly attribute CryptoPk pk;
   
  readonly attribute CryptoSym sym;
    set algorithm(algorithm){ },
  readonly attribute CryptoHash hash;
   
  readonly attribute CryptoHmac hmac;
    get algorithm(){ },
};


    // Generate a keypair and then execute the callback function
dictionary CryptoKeyPair {
    generateKeypair: function ( function callback( aPublicKey ) { } ) {  },
  long created;
  DOMString privKey;
  DOMString pubKey;
  DOMString salt;
  DOMString iv;
  DOMString algorithm;
}


    // encrypt a plainText
dictionary CryptoConfiguration {
    encrypt: function ( plainText, publicKey, function callback (cipherMessageObject) ) {  } ) {  },
  CryptoKeyPair keyID;
};


    // decrypt a cipherMessage
interface PKCryptoMessage {
    decrypt: function ( cipherMessageObject, function callback ( plainText ) { } ) {  },     
  attribute DOMString cryptoMessage;
  attribute DOMString wrappedKey;
  attribute DOMString pubKey;
  attribute DOMString salt;
  attribute DOMString iv;
  attribute DOMString algorithm;
};


    // sign a message
[Callback=FunctionOnly, NoInterfaceObject] interface GenerateKeypairCallback {
    sign: function ( plainText, function callback ( signature ) { } ) {  },     
  void onsuccess(DOMString pubKey);
};


    // verify a signature
[Callback=FunctionOnly, NoInterfaceObject] interface PKEncryptCallback {
    verify: function ( signature, plainText, function callback ( boolean ) { } ) {  },
  void onsuccess(PKCryptoMessage message);
  },
};
 
  sym: {
    // Symmetric Crypto API


    get algorithm()
[Callback=FunctionOnly, NoInterfaceObject] interface PKDecryptCallback {
  void onsuccess(DOMString plainText);
};


    set algorithm(algorithm),
[Callback=FunctionOnly, NoInterfaceObject] interface PKSignCallback {
   
  void onsuccess(DOMString signature);
    // create a new symmetric key
};
    generateKey: function (function callback ( key ){ }) { },
   
    // encrypt some data
    encrypt: function (plainText, key, function callback( cipherText ) { }) {  },
   
    // decrypt some data
    decrypt: function (cipherText, key, function callback( plainText ) { }) {  },
  },


  hash: {
[Callback=FunctionOnly, NoInterfaceObject] interface PKVerifyCallback {
    set algorithm( algorithm ) { },
  void onsuccess(boolean verified);
};


    get algorithm( ) { },
interface CryptoPk {


    createHash: function (function callback (hash) {}) {  }
  attribute DOMString algorithm;
  },


  hmac: {
  void generateKeypair(GenerateKeypairCallback callback);
    get algorithm() { },


    set algorithm(algorithm){ },
  void encrypt(DOMString plainText, DOMString pubKey, PKEncryptCallback callback);


    createHMAC: function (plaintext, key, function callback( mac ){ }) { },
  void decrypt(PKCryptoMessage message, PKDecryptCallback callback);
 
  void sign(DOMString plainText, PKSignCallback callback);
 
  void verify(DOMString signature, DOMString plainText, PKVerifyCallback callback);
 
};
 
[Callback=FunctionOnly, NoInterfaceObject] interface SymGenerateKeyCallback {
  void onsuccess(DOMString symKey);
};
 
[Callback=FunctionOnly, NoInterfaceObject] interface SymEncryptCallback {
  void onsuccess(DOMString cipherText);
};
 
[Callback=FunctionOnly, NoInterfaceObject] interface SymDecryptCallback {
  void onsuccess(DOMString plainText);
};
 
interface CryptoSym {
 
  attribute DOMString algorithm;
 
  void generateKey(SymGenerateKeyCallback callback);
 
  void encrypt(DOMString plainText, DOMString symKey, SymEncryptCallback callback);
 
  void decrypt(DOMString cipherText, DOMString symKey, SymDecryptCallback callback);
 
};
 
[Callback=FunctionOnly, NoInterfaceObject] interface hashCallback {
  void onsuccess(DOMString hash);
};
 
interface CryptoHash {
 
  attribute DOMString algorithm;
 
  void createHash(DOMString plainText, hashCallback callback);
 
};
 
[Callback=FunctionOnly, NoInterfaceObject] interface createHMACCallback {
  void onsuccess(DOMString hmac);
};
 
[Callback=FunctionOnly, NoInterfaceObject] interface verifyHMACCallback {
  void onsuccess(boolean verified);
};
 
interface CryptoHmac {
 
  attribute DOMString algorithm;
 
  void createHMAC(DOMString plainText, DOMString pubKey, createHMACCallback callback);
 
  void verifyHMAC(DOMString plainText, verifyHMACCallback callback);
 
};


    verifyHMAC: function(plaintext, key, receivedMac, function callback( booleanVerified ){ }) { }
  }
}
</pre>
</pre>


== Notes ==
== Notes ==
564

edits

Navigation menu