Privacy/Features/DOMCryptAPISpec/Latest: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
Line 56: Line 56:
};
};


dictionary CryptoKeyPair {
interface PKCryptoPublicKey {
   long created;
   readonly attribute DOMString pubKey;
  DOMString privKey;
   readonly attribute DOMString algorithm;
  DOMString pubKey;
   readonly attribute integer created;
   DOMString salt;
   DOMString iv;
  DOMString algorithm;  
}
}
dictionary CryptoConfiguration {
  CryptoKeyPair keyID;
};


interface PKCryptoMessage {
interface PKCryptoMessage {
   attribute DOMString cryptoMessage;
   attribute DOMString cryptoMessage;  
  attribute DOMString wrappedKey;
  attribute DOMString pubKey;
  attribute DOMString salt;
  attribute DOMString iv;
   attribute DOMString algorithm;  
   attribute DOMString algorithm;  
};
};
Line 120: Line 109:
};
};


[Callback=FunctionOnly, NoInterfaceObject] interface SymGenerateKeyCallback {
// Use JWE as the crypto object?, or something like the following:
   void onsuccess(DOMString symKey);
interface SymCipherObject {
   attribute DOMString cipherString;
  attribute DOMString algorithm;
  attribute DOMString symKeyID;
  // What is missing here?
};
};


[Callback=FunctionOnly, NoInterfaceObject] interface SymEncryptCallback {
[Callback=FunctionOnly, NoInterfaceObject] interface SymEncryptCallback {
   void onsuccess(DOMString cipherText);
   void onsuccess(SymCipherObject cipherObject);
};
};


Line 136: Line 129:
   attribute DOMString algorithm;
   attribute DOMString algorithm;


   void generateKey(SymGenerateKeyCallback callback);
   void encrypt(DOMString plainText, SymEncryptCallback callback);


  void encrypt(DOMString plainText, DOMString symKey, SymEncryptCallback callback);
   void decrypt(DOMString cipherText, DOMString symKeyID, SymDecryptCallback callback);
 
   void decrypt(DOMString cipherText, DOMString symKey, SymDecryptCallback callback);


};
};
Line 173: Line 164:


};
};
</pre>
</pre>



Revision as of 05:52, 14 July 2011

DOMCrypt 'window.mozCrypto' Specification

DRAFT
Version 0.2
Updated 2011-06-03
Author
David Dahl <ddahl@mozilla.com>

Introduction

This document describes a proposed Javascript Cryptography API available in web browsers to allow any web page script the ability to generate asymmetric key pairs, encrypt, decrypt (asymmetric and symmetric crypto), sign, verify, HMAC, and hash data ( via a variety of algorithms ).

Terms

DOMCrypt
A generic label for the entire crypto API originating in the open source project 'DOMCrypt'
window.cipher
The now deprecated proposed window property name for this API
window.mozCrypto
The temporary window property used to distinguish this new API from the current window.crypto property. The consensus so far is to add this API to the window.crypto property
window.crypto
The existing DOM property where this API should be integrated
Key Pair
An asymmetric pair of encryption keys. A Public Key which is used by others to encrypted data for you to decrypt with your Private Key. Key pairs are bound to the origin
Public Key
The public half of an asymmetric key pair
Private Key
The private half of an asymmetric key pair
Symmetric Key
an encryption key used for symmetric encryption

Browser Window property WebIDL

window.mozCrypto

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.

 
[Supplemental]
interface Crypto {
  readonly attribute CryptoPk pk;
  readonly attribute CryptoSym sym;
  readonly attribute CryptoHash hash;
  readonly attribute CryptoHmac hmac;
};

interface PKCryptoPublicKey {
  readonly attribute DOMString pubKey;
  readonly attribute DOMString algorithm;
  readonly attribute integer created;
}

interface PKCryptoMessage {
  attribute DOMString cryptoMessage; 
  attribute DOMString algorithm; 
};

[Callback=FunctionOnly, NoInterfaceObject] interface GenerateKeypairCallback {
  void onsuccess(DOMString pubKey);
};

[Callback=FunctionOnly, NoInterfaceObject] interface GetPublicKeyCallback {
  void onsuccess(DOMString pubKey);
};

[Callback=FunctionOnly, NoInterfaceObject] interface PKEncryptCallback {
  void onsuccess(PKCryptoMessage message);
};

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

[Callback=FunctionOnly, NoInterfaceObject] interface PKSignCallback {
  void onsuccess(DOMString signature);
};

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

interface CryptoPk {

  attribute DOMString algorithm;

  void generateKeypair(GenerateKeypairCallback callback);

  void getPublicKey(GetPublicKeyCallback callback);

  void encrypt(DOMString plainText, DOMString pubKey, PKEncryptCallback callback);

  void decrypt(PKCryptoMessage message, PKDecryptCallback callback);

  void sign(DOMString plainText, PKSignCallback callback);

  void verify(DOMString signature, DOMString pubKey, DOMString plainText, PKVerifyCallback callback);

};

// Use JWE as the crypto object?, or something like the following:
interface SymCipherObject {
  attribute DOMString cipherString; 
  attribute DOMString algorithm;
  attribute DOMString symKeyID;
  // What is missing here?
};

[Callback=FunctionOnly, NoInterfaceObject] interface SymEncryptCallback {
  void onsuccess(SymCipherObject cipherObject);
};

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

interface CryptoSym {

  attribute DOMString algorithm;

  void encrypt(DOMString plainText, SymEncryptCallback callback);

  void decrypt(DOMString cipherText, DOMString symKeyID, 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);

};

Notes

  • Each origin will only have access to the asymmetric private key generated for it. This will minimize the need for any kind of access control dialog for key usage.
  • The configuration object should be removed from the IDL as we move to a set of keys per domain

References