2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-05-15 14:20:00 +04:00
|
|
|
/* 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:
|
2014-07-19 17:24:00 +04:00
|
|
|
uint8_t* Assign(const CryptoBuffer& aData);
|
2014-05-15 14:20:00 +04:00
|
|
|
uint8_t* Assign(const uint8_t* aData, uint32_t aLength);
|
2016-02-09 18:43:00 +03:00
|
|
|
uint8_t* Assign(const nsACString& aString);
|
2014-05-15 14:20:00 +04:00
|
|
|
uint8_t* Assign(const SECItem* aItem);
|
2016-04-15 19:29:12 +03:00
|
|
|
uint8_t* Assign(const InfallibleTArray<uint8_t>& aData);
|
2014-05-15 14:20:00 +04:00
|
|
|
uint8_t* Assign(const ArrayBuffer& aData);
|
|
|
|
uint8_t* Assign(const ArrayBufferView& aData);
|
|
|
|
uint8_t* Assign(const ArrayBufferViewOrArrayBuffer& aData);
|
|
|
|
uint8_t* Assign(const OwningArrayBufferViewOrArrayBuffer& aData);
|
|
|
|
|
2016-04-15 19:29:12 +03:00
|
|
|
uint8_t* AppendSECItem(const SECItem* aItem);
|
|
|
|
uint8_t* AppendSECItem(const SECItem& aItem);
|
|
|
|
|
2014-05-26 14:05:00 +04:00
|
|
|
template<typename T,
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
JSObject* UnwrapArray(JSObject*),
|
2015-11-25 21:04:50 +03:00
|
|
|
void GetLengthAndDataAndSharedness(JSObject*, uint32_t*, bool*, T**)>
|
|
|
|
uint8_t* Assign(const TypedArray_base<T, UnwrapArray,
|
|
|
|
GetLengthAndDataAndSharedness>& aArray)
|
2014-05-26 14:05:00 +04:00
|
|
|
{
|
Bug 999651, bug 995679, bug 1009952, bug 1011007, bug 991981. r=sfink, r=shu, r=jandem, r=jdm, r=luke, r=bbouvier, r=nmatsakis, r=bz, r=ehsan, r=jgilbert, r=smaug, r=sicking, r=terrence, r=bholley, r=bent, r=efaust, r=jorendorff
2014-05-28 01:32:41 +04:00
|
|
|
aArray.ComputeLengthAndData();
|
|
|
|
return Assign(aArray.Data(), aArray.Length());
|
2014-05-26 14:05:00 +04:00
|
|
|
}
|
|
|
|
|
2014-07-19 17:25:00 +04:00
|
|
|
nsresult FromJwkBase64(const nsString& aBase64);
|
2017-01-09 23:22:49 +03:00
|
|
|
nsresult ToJwkBase64(nsString& aBase64) const;
|
2014-07-20 08:38:44 +04:00
|
|
|
bool ToSECItem(PLArenaPool* aArena, SECItem* aItem) const;
|
2014-09-27 22:22:57 +04:00
|
|
|
JSObject* ToUint8Array(JSContext* aCx) const;
|
2016-04-13 20:20:37 +03:00
|
|
|
bool ToNewUnsignedBuffer(uint8_t** aBuf, uint32_t* aBufLen) const;
|
2014-05-15 14:20:00 +04:00
|
|
|
|
|
|
|
bool GetBigIntValue(unsigned long& aRetVal);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_CryptoBuffer_h
|