15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 2521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 57757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * modification, are permitted provided that the following conditions are 67757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 87757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * * Redistributions of source code must retain the above copyright 97757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * notice, this list of conditions and the following disclaimer. 107757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * * Redistributions in binary form must reproduce the above 117757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * copyright notice, this list of conditions and the following disclaimer 127757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * in the documentation and/or other materials provided with the 137757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * distribution. 147757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * * Neither the name of Google Inc. nor the names of its 157757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * contributors may be used to endorse or promote products derived from 167757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * this software without specific prior written permission. 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 187757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 197757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 207757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 217757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 227757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 237757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 247757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 257757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 267757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 277757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 287757ec2eadfa2dd8ac2aeed0a4399e9b07ec38cbBen Murdoch * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 295c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 31d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)// http://www.w3.org/TR/WebCryptoAPI/#subtlecrypto-interface 32d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) 33d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)typedef DOMString KeyFormat; 34197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtypedef DOMString KeyUsage; // from CryptoKey interface 35d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) 36d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)// FIXME: use below; needs support for union types http://crbug.com/240176 37d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData; 38d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) 395c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)[ 4010f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch GarbageCollected, 41d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) NoInterfaceObject, 42521d96ec04ace82590870fb04353ec4f82bb150fTorne (Richard Coles)] interface SubtleCrypto { 43197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise encrypt(Dictionary algorithm, CryptoKey key, ArrayBuffer data); 44197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise encrypt(Dictionary algorithm, CryptoKey key, ArrayBufferView data); 45323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 46197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise decrypt(Dictionary algorithm, CryptoKey key, ArrayBuffer data); 47197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise decrypt(Dictionary algorithm, CryptoKey key, ArrayBufferView data); 48323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 49197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise sign(Dictionary algorithm, CryptoKey key, ArrayBuffer data); 50197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise sign(Dictionary algorithm, CryptoKey key, ArrayBufferView data); 51323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 52197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // FIXME: should be: Promise verify(Dictionary algorithm, CryptoKey key, CryptoOperationData signature, CryptoOperationData data); 53197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState, Custom, ImplementedAs=verifySignature] Promise verify(Dictionary algorithm, CryptoKey key, object signature, object data); 54323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 55d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) [CallWith=ScriptState] Promise digest(Dictionary algorithm, ArrayBuffer data); 56d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) [CallWith=ScriptState] Promise digest(Dictionary algorithm, ArrayBufferView data); 5702772c6a72f1ee0b226341a4f4439970c29fc861Ben Murdoch 58d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) [CallWith=ScriptState] Promise generateKey(Dictionary algorithm, boolean extractable, DOMString[] keyUsages); 59323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 60d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) [CallWith=ScriptState] Promise importKey(KeyFormat format, ArrayBuffer keyData, Dictionary algorithm, boolean extractable, KeyUsage[] keyUsages); 61d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles) [CallWith=ScriptState] Promise importKey(KeyFormat format, ArrayBufferView keyData, Dictionary algorithm, boolean extractable, KeyUsage[] keyUsages); 625d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles) [CallWith=ScriptState] Promise importKey(KeyFormat format, Dictionary keyData, Dictionary algorithm, boolean extractable, KeyUsage[] keyUsages); 63323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 64197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise exportKey(KeyFormat format, CryptoKey key); 65a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) 66197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise wrapKey(KeyFormat format, CryptoKey key, CryptoKey wrappingKey, Dictionary wrapAlgorithm); 67323480423219ecd77329f8326dc5e0e3b50926d4Torne (Richard Coles) 68197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise unwrapKey(KeyFormat format, ArrayBuffer wrappedKey, CryptoKey unwrappingKey, Dictionary unwrapAlgorithm, Dictionary unwrappedKeyAlgorithm, boolean extractable, KeyUsage[] keyUsages); 69197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch [CallWith=ScriptState] Promise unwrapKey(KeyFormat format, ArrayBufferView wrappedKey, CryptoKey unwrappingKey, Dictionary unwrapAlgorithm, Dictionary unwrappedKeyAlgorithm, boolean extractable, KeyUsage[] keyUsages); 705c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 71