/* -*- 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/. */
uint8_t* CryptoBuffer::Assign(const CryptoBuffer& aData) { // Same as in nsTArray_Impl::operator=, but return the value // returned from ReplaceElementsAt to enable OOM detection return ReplaceElementsAt(0, Length(), aData.Elements(), aData.Length(),
fallible);
}
// Helpers to encode/decode JWK's special flavor of Base64 // * No whitespace // * No padding // * URL-safe character set
nsresult CryptoBuffer::FromJwkBase64(const nsString& aBase64) {
NS_ConvertUTF16toUTF8 temp(aBase64);
temp.StripWhitespace();
if (!::SECITEM_AllocItem(aArena, aItem, Length())) { returnfalse;
} // If this CryptoBuffer is of 0 length, aItem->data will be null. Passing // null to memcpy is not valid, even if the length is 0, so return early. if (!aItem->data) {
MOZ_ASSERT(Length() == 0); returntrue;
}
memcpy(aItem->data, Elements(), Length()); returntrue;
}
// "BigInt" comes from the WebCrypto spec // ("unsigned long" isn't very "big", of course) // Likewise, the spec calls for big-endian ints bool CryptoBuffer::GetBigIntValue(unsignedlong& aRetVal) { if (Length() > sizeof(aRetVal)) { returnfalse;
}
aRetVal = 0; for (size_t i = 0; i < Length(); ++i) {
aRetVal = (aRetVal << 8) + ElementAt(i);
} returntrue;
}
} // namespace mozilla::dom
¤ Dauer der Verarbeitung: 0.33 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.