A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on IRC (such as one of these permanent autoconfirmed members).

Difference between revisions of "Crypto"

From WHATWG Wiki
Jump to: navigation, search
(getRandomValues)
(getRandomValues)
Line 21: Line 21:
 
==getRandomValues==
 
==getRandomValues==
  
The ''getRandomValues'' method fills ''array'' with random data.  Specifically, if ''array'' is an [http://www.khronos.org/registry/typedarray/specs/latest/#6 ArrayBufferView] of an integer type (i.e., Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, or Uint32Array), then all the elements of ''array'' are overwritten with ''cryptographically random values'' (see below).  If ''array'' is not of an appropriate type, ''getRandomValues'' throws a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-type_mismatch_err TYPE_MISMATCH_ERR].
+
The ''getRandomValues'' method fills ''array'' with random data.  Specifically, if ''array'' is an [http://www.khronos.org/registry/typedarray/specs/latest/#6 ArrayBufferView] of an integer type (i.e., Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, or Uint32Array), then all the elements of ''array'' are overwritten with ''cryptographically random values''.  If ''array'' is not of an appropriate type, ''getRandomValues'' throws a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-type_mismatch_err TYPE_MISMATCH_ERR].  If no ''cryptographically random values'' are available, ''getRandomValues'' throws a [http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#dom-domexception-not_supported_err NOT_SUPPORTED_ERR].

Revision as of 21:58, 14 February 2011

Overview

This document describes a proposal for the window.crypto API.

Interface

[Suplemental, NoInterfaceObject]
interface Window {
  readonly attribute Crypto crypto;
};

[NoInterfaceObject]
interface Crypto {
  void getRandomValues(in ArrayBufferView array);
};

Methods

getRandomValues

The getRandomValues method fills array with random data. Specifically, if array is an ArrayBufferView of an integer type (i.e., Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, or Uint32Array), then all the elements of array are overwritten with cryptographically random values. If array is not of an appropriate type, getRandomValues throws a TYPE_MISMATCH_ERR. If no cryptographically random values are available, getRandomValues throws a NOT_SUPPORTED_ERR.