mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-27 20:25:44 +00:00
e6dd50ba10
This patch implements the W3C Web Authentication API from https://www.w3.org/TR/webauthn/, currently the 28 September 2016 working draft. It utilizes a tentative binding of the U2F NSS Soft Token to provide authentication services while waiting on Bug 1245527 to support USB HID-based U2F tokens. This binding is not in the specification yet, so it should be considered an experiment to help the specification move fowrard. There are also a handful of deviations from the specification's WebIDL, which are annotated with comments in WebAuthentication.webidl. There are no tests in this commit; they are in Part 4 of this commit series. There is a small script online at https://webauthn.bin.coffee/ to exercise this code, but it doesn't do any automated checks. There are also a handful of TODOS: 1) The algorithm to relax the same-origin restriction is in Part 3. 2) The use of AlgorithmIdentifier and having a way to coerce an object to a string is still missing. 3) Timeouts and deadlines aren't there, and are pending reworking how the nsIU2FToken interface works. UPDATED: - Address qdot, keeler review comments (thanks!) - Address more qdot, keeler review comments (thanks!) MozReview-Commit-ID: JITapI38iOh --HG-- extra : rebase_source : 9a09e852dd0c8dc47f42dabbcf8b845a6828b225
59 lines
2.0 KiB
C++
59 lines
2.0 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
|
|
#ifndef mozilla_dom_CryptoBuffer_h
|
|
#define mozilla_dom_CryptoBuffer_h
|
|
|
|
#include "nsTArray.h"
|
|
#include "seccomon.h"
|
|
#include "mozilla/dom/TypedArray.h"
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
class ArrayBufferViewOrArrayBuffer;
|
|
class OwningArrayBufferViewOrArrayBuffer;
|
|
|
|
class CryptoBuffer : public FallibleTArray<uint8_t>
|
|
{
|
|
public:
|
|
uint8_t* Assign(const CryptoBuffer& aData);
|
|
uint8_t* Assign(const uint8_t* aData, uint32_t aLength);
|
|
uint8_t* Assign(const nsACString& aString);
|
|
uint8_t* Assign(const SECItem* aItem);
|
|
uint8_t* Assign(const InfallibleTArray<uint8_t>& aData);
|
|
uint8_t* Assign(const ArrayBuffer& aData);
|
|
uint8_t* Assign(const ArrayBufferView& aData);
|
|
uint8_t* Assign(const ArrayBufferViewOrArrayBuffer& aData);
|
|
uint8_t* Assign(const OwningArrayBufferViewOrArrayBuffer& aData);
|
|
|
|
uint8_t* AppendSECItem(const SECItem* aItem);
|
|
uint8_t* AppendSECItem(const SECItem& aItem);
|
|
|
|
template<typename T,
|
|
JSObject* UnwrapArray(JSObject*),
|
|
void GetLengthAndDataAndSharedness(JSObject*, uint32_t*, bool*, T**)>
|
|
uint8_t* Assign(const TypedArray_base<T, UnwrapArray,
|
|
GetLengthAndDataAndSharedness>& aArray)
|
|
{
|
|
aArray.ComputeLengthAndData();
|
|
return Assign(aArray.Data(), aArray.Length());
|
|
}
|
|
|
|
nsresult FromJwkBase64(const nsString& aBase64);
|
|
nsresult ToJwkBase64(nsString& aBase64) const;
|
|
bool ToSECItem(PLArenaPool* aArena, SECItem* aItem) const;
|
|
JSObject* ToUint8Array(JSContext* aCx) const;
|
|
bool ToNewUnsignedBuffer(uint8_t** aBuf, uint32_t* aBufLen) const;
|
|
|
|
bool GetBigIntValue(unsigned long& aRetVal);
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_dom_CryptoBuffer_h
|