mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-13 20:14:57 -10:00
Adds a module that provides a reversable mapping between an number and a UUID. Recovering the number requires knowledge of a common secret key. The implementation is based on AES-128 encryption / decryption, mainly for its properties than it actually needing to be AES-128. Differential Revision: https://phabricator.services.mozilla.com/D304639
37 lines
1.3 KiB
Plaintext
37 lines
1.3 KiB
Plaintext
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
/**
|
|
* Maps 53-bit integers to opaque UUID strings and back.
|
|
* (The actual type is a 64-bit integer, but JS cannot represent numbers with
|
|
* precision beyond MAX_SAFE_INTEGER, 2^53-1).
|
|
*
|
|
* Each integer maps to a unique UUID that reveals nothing about the
|
|
* original value to anyone who does not hold the key. Call init() once
|
|
* with a random 16-byte key, then use toUUID/fromUUID freely.
|
|
*/
|
|
[scriptable, builtinclass, uuid(424ecfce-456d-42ce-8d22-ee934f53a43f)]
|
|
interface nsIKeyedUUIDMapper : nsISupports {
|
|
/**
|
|
* Initialize with a 16-byte key. May be called again to change the key.
|
|
*
|
|
* Throws NS_ERROR_INVALID_ARG if aKey is not 16 bytes.
|
|
*/
|
|
void init(in Array<uint8_t> aKey);
|
|
|
|
/**
|
|
* Throws NS_ERROR_INVALID_ARG if aValue is 2^53 or larger.
|
|
*/
|
|
AUTF8String toUUID(in unsigned long long aValue);
|
|
|
|
/**
|
|
* Throws NS_ERROR_INVALID_ARG if aUUID is not a valid UUID string,
|
|
* or not a value that fromUUID could have produced for the key,
|
|
* i.e. if the UUID maps to a number outside the 53-bit range.
|
|
*/
|
|
unsigned long long fromUUID(in AUTF8String aUUID);
|
|
};
|