Merge autoland to mozilla-central a=merge

This commit is contained in:
Razvan Maries 2020-11-06 11:32:19 +02:00
Родитель ad08fd8438 78b884f32d
Коммит a5d9abfda1
45 изменённых файлов: 32145 добавлений и 439 удалений

Просмотреть файл

@ -550,6 +550,13 @@ class UrlbarController {
resultIndex,
1
);
if (this.input.searchMode) {
Services.telemetry.keyedScalarAdd(
`urlbar.picked.searchmode.${this.input.searchMode.entry}`,
resultIndex,
1
);
}
// These histograms should be removed after a deprecation time where we'll
// confirm goodness of the new scalar above.

Просмотреть файл

@ -215,6 +215,26 @@ urlbar.picked.*
- ``visiturl``
The user typed string can be directly visited.
urlbar.picked.searchmode.*
This is a set of keyed scalars whose values are uints incremented each time a
result is picked from the Urlbar while the Urlbar is in search mode. The
suffix on the scalar name is the search mode entry point. The keys for the
scalars are the 0-based index of the result in the urlbar panel when it was
picked.
.. note::
These scalars share elements of both ``urlbar.picked.*`` and
``urlbar.searchmode.*``. Scalar name suffixes are search mode entry points,
like ``urlbar.searchmode.*``. The keys for these scalars are result indices,
like ``urlbar.picked.*``.
.. note::
These data are a subset of the data recorded by ``urlbar.picked.*``. For
example, if the user enters search mode by clicking a one-off then selects
a Google search suggestion at index 2, we would record in **both**
``urlbar.picked.searchsuggestion`` and ``urlbar.picked.searchmode.oneoff``.
Event Telemetry
---------------

Просмотреть файл

@ -9,11 +9,12 @@
"use strict";
const SCALAR_PREFIX = "urlbar.searchmode.";
const ENGINE_NAME = "MozSearch";
const ENGINE_DOMAIN = "example.com";
const ENTRY_SCALAR_PREFIX = "urlbar.searchmode.";
const PICKED_SCALAR_PREFIX = "urlbar.picked.searchmode.";
const ENGINE_ALIAS = "alias";
const TEST_QUERY = "test";
let engineName;
let engineDomain;
// The preference to enable suggestions.
const SUGGEST_PREF = "browser.search.suggest.enabled";
@ -34,30 +35,50 @@ XPCOMUtils.defineLazyServiceGetter(
);
/**
* Asserts that search mode telemetry was recorded correctly.
* Asserts that search mode telemetry was recorded correctly. Checks both the
* urlbar.searchmode.* and urlbar.searchmode_picked.* probes.
* @param {string} entry
* @param {string} key
* A search mode entry point.
* @param {string} engineOrSource
* An engine name or a search mode source.
* @param {number} [resultIndex]
* The index of the result picked while in search mode. Only pass this
* parameter if a result is picked.
*/
function assertSearchModeScalar(entry, key) {
function assertSearchModeScalars(entry, engineOrSource, resultIndex = -1) {
// Check if the urlbar.searchmode.entry scalar contains the expected value.
const scalars = TelemetryTestUtils.getProcessScalars("parent", true, false);
TelemetryTestUtils.assertKeyedScalar(scalars, SCALAR_PREFIX + entry, key, 1);
TelemetryTestUtils.assertKeyedScalar(
scalars,
ENTRY_SCALAR_PREFIX + entry,
engineOrSource,
1
);
for (let e of UrlbarUtils.SEARCH_MODE_ENTRY) {
if (e == entry) {
Assert.equal(
Object.keys(scalars[SCALAR_PREFIX + entry]).length,
Object.keys(scalars[ENTRY_SCALAR_PREFIX + entry]).length,
1,
`This search must only increment one entry in the correct scalar: ${e}`
);
} else {
Assert.ok(
!scalars[SCALAR_PREFIX + e],
!scalars[ENTRY_SCALAR_PREFIX + e],
`No other urlbar.searchmode scalars should be recorded. Checking ${e}`
);
}
}
if (resultIndex >= 0) {
TelemetryTestUtils.assertKeyedScalar(
scalars,
PICKED_SCALAR_PREFIX + entry,
resultIndex,
1
);
}
Services.telemetry.clearScalars();
Services.telemetry.clearEvents();
}
@ -74,20 +95,21 @@ add_task(async function setup() {
],
});
// Create a new search engine.
await Services.search.addEngineWithDetails(ENGINE_NAME, {
alias: ENGINE_ALIAS,
method: "GET",
template: `http://${ENGINE_DOMAIN}/?q={searchTerms}`,
});
// Create an engine to generate search suggestions and add it as default
// for this test.
const url =
getRootDirectory(gTestPath) + "usageTelemetrySearchSuggestions.xml";
let suggestionEngine = await Services.search.addOpenSearchEngine(url, "");
suggestionEngine.alias = ENGINE_ALIAS;
engineDomain = suggestionEngine.getResultDomain();
engineName = suggestionEngine.name;
// Make it the default search engine.
let engine = Services.search.getEngineByName(ENGINE_NAME);
let originalEngine = await Services.search.getDefault();
await Services.search.setDefault(engine);
await Services.search.setDefault(suggestionEngine);
// And the first one-off engine.
await Services.search.moveEngine(engine, 0);
await Services.search.moveEngine(suggestionEngine, 0);
// Enable local telemetry recording for the duration of the tests.
let oldCanRecord = Services.telemetry.canRecordExtended;
@ -110,7 +132,7 @@ add_task(async function setup() {
registerCleanupFunction(async function() {
Services.telemetry.canRecordExtended = oldCanRecord;
await Services.search.setDefault(originalEngine);
await Services.search.removeEngine(engine);
await Services.search.removeEngine(suggestionEngine);
await PlacesUtils.history.clear();
Services.telemetry.setEventRecordingEnabled("navigation", false);
UrlbarTestUtils.uninit();
@ -130,8 +152,10 @@ add_task(async function test_oneoff_remote() {
});
// Enters search mode by clicking a one-off.
await UrlbarTestUtils.enterSearchMode(window);
assertSearchModeScalar("oneoff", "other");
await UrlbarTestUtils.exitSearchMode(window);
let loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
EventUtils.synthesizeKey("KEY_Enter");
await loadPromise;
assertSearchModeScalars("oneoff", "other", 0);
BrowserTestUtils.removeTab(tab);
});
@ -151,8 +175,11 @@ add_task(async function test_oneoff_local() {
await UrlbarTestUtils.enterSearchMode(window, {
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
});
assertSearchModeScalar("oneoff", "history");
await UrlbarTestUtils.exitSearchMode(window);
let loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
EventUtils.synthesizeKey("KEY_ArrowDown");
EventUtils.synthesizeKey("KEY_Enter");
await loadPromise;
assertSearchModeScalars("oneoff", "history", 0);
BrowserTestUtils.removeTab(tab);
});
@ -177,7 +204,7 @@ add_task(async function test_oneoff_amazon() {
await UrlbarTestUtils.enterSearchMode(window, {
engineName: "Amazon.com",
});
assertSearchModeScalar("oneoff", "Amazon");
assertSearchModeScalars("oneoff", "Amazon");
await UrlbarTestUtils.exitSearchMode(window);
BrowserTestUtils.removeTab(tab);
@ -204,7 +231,7 @@ add_task(async function test_oneoff_wikipedia() {
await UrlbarTestUtils.enterSearchMode(window, {
engineName: "Wikipedia (en)",
});
assertSearchModeScalar("oneoff", "Wikipedia");
assertSearchModeScalars("oneoff", "Wikipedia");
await UrlbarTestUtils.exitSearchMode(window);
BrowserTestUtils.removeTab(tab);
@ -228,19 +255,18 @@ add_task(async function test_shortcut() {
await searchPromise;
await UrlbarTestUtils.assertSearchMode(window, {
engineName: ENGINE_NAME,
engineName,
source: UrlbarUtils.RESULT_SOURCE.SEARCH,
entry: "shortcut",
});
assertSearchModeScalar("shortcut", "other");
await UrlbarTestUtils.exitSearchMode(window);
assertSearchModeScalars("shortcut", "other");
BrowserTestUtils.removeTab(tab);
});
// Enters search mode by selecting a Top Site from the Urlbar.
add_task(async function test_topsites_urlbar() {
// Disable suggestions to avoid hitting Wikipedia servers.
// Disable suggestions to avoid hitting Amazon servers.
await SpecialPowers.pushPrefEnv({
set: [[SUGGEST_PREF, false]],
});
@ -276,7 +302,7 @@ add_task(async function test_topsites_urlbar() {
engineName: amazonSearch.result.payload.engine,
entry: "topsites_urlbar",
});
assertSearchModeScalar("topsites_urlbar", "Amazon");
assertSearchModeScalars("topsites_urlbar", "Amazon");
await UrlbarTestUtils.exitSearchMode(window);
BrowserTestUtils.removeTab(tab);
@ -314,11 +340,10 @@ add_task(async function test_keywordoffer() {
await searchPromise;
await UrlbarTestUtils.assertSearchMode(window, {
engineName: ENGINE_NAME,
engineName,
entry: "keywordoffer",
});
assertSearchModeScalar("keywordoffer", "other");
await UrlbarTestUtils.exitSearchMode(window);
assertSearchModeScalars("keywordoffer", "other");
BrowserTestUtils.removeTab(tab);
});
@ -341,11 +366,10 @@ add_task(async function test_typed() {
await searchPromise;
await UrlbarTestUtils.assertSearchMode(window, {
engineName: ENGINE_NAME,
engineName,
entry: "typed",
});
assertSearchModeScalar("typed", "other");
await UrlbarTestUtils.exitSearchMode(window);
assertSearchModeScalars("typed", "other");
BrowserTestUtils.removeTab(tab);
});
@ -353,6 +377,10 @@ add_task(async function test_typed() {
// Enters search mode by calling the same function called by the Search
// Bookmarks menu item in Library > Bookmarks.
add_task(async function test_bookmarkmenu() {
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
let searchPromise = UrlbarTestUtils.promiseSearchComplete(window);
PlacesCommandHook.searchBookmarks();
await searchPromise;
@ -361,8 +389,8 @@ add_task(async function test_bookmarkmenu() {
source: UrlbarUtils.RESULT_SOURCE.BOOKMARKS,
entry: "bookmarkmenu",
});
assertSearchModeScalar("bookmarkmenu", "bookmarks");
await UrlbarTestUtils.exitSearchMode(window);
assertSearchModeScalars("bookmarkmenu", "bookmarks");
BrowserTestUtils.removeTab(tab);
});
// Enters search mode by calling the same function called by the Search Tabs
@ -376,8 +404,7 @@ add_task(async function test_tabmenu() {
source: UrlbarUtils.RESULT_SOURCE.TABS,
entry: "tabmenu",
});
assertSearchModeScalar("tabmenu", "tabs");
await UrlbarTestUtils.exitSearchMode(window);
assertSearchModeScalars("tabmenu", "tabs");
});
// Enters search mode by performing a search handoff on about:privatebrowsing.
@ -403,10 +430,10 @@ add_task(async function test_handoff_pbm() {
await new Promise(r => EventUtils.synthesizeKey("f", {}, win, r));
await searchPromise;
await UrlbarTestUtils.assertSearchMode(win, {
engineName: ENGINE_NAME,
engineName,
entry: "handoff",
});
assertSearchModeScalar("handoff", "other");
assertSearchModeScalars("handoff", "other");
await UrlbarTestUtils.exitSearchMode(win);
await UrlbarTestUtils.promisePopupClose(win);
@ -419,6 +446,11 @@ add_task(async function test_touchbar() {
return;
}
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"about:blank"
);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: TEST_QUERY,
@ -430,8 +462,12 @@ add_task(async function test_touchbar() {
source: UrlbarUtils.RESULT_SOURCE.HISTORY,
entry: "touchbar",
});
assertSearchModeScalar("touchbar", "history");
await UrlbarTestUtils.exitSearchMode(window);
let loadPromise = BrowserTestUtils.browserLoaded(tab.linkedBrowser);
EventUtils.synthesizeKey("KEY_ArrowDown");
EventUtils.synthesizeKey("KEY_Enter");
await loadPromise;
assertSearchModeScalars("touchbar", "history", 0);
BrowserTestUtils.removeTab(tab);
});
// Enters search mode by selecting a tab-to-search result.
@ -446,11 +482,11 @@ add_task(async function test_tabtosearch() {
["browser.urlbar.tabToSearch.onboard.maxShown", 0],
],
});
await PlacesTestUtils.addVisits([`https://${ENGINE_DOMAIN}/`]);
await PlacesTestUtils.addVisits([`http://${engineDomain}/`]);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: ENGINE_DOMAIN.slice(0, 4),
value: engineDomain.slice(0, 4),
});
let tabToSearchResult = (
await UrlbarTestUtils.waitForAutocompleteResultAt(window, 1)
@ -462,7 +498,7 @@ add_task(async function test_tabtosearch() {
);
Assert.equal(
tabToSearchResult.payload.engine,
ENGINE_NAME,
engineName,
"The tab-to-search result is for the correct engine."
);
await UrlbarTestUtils.assertSearchMode(window, null);
@ -478,11 +514,11 @@ add_task(async function test_tabtosearch() {
await searchPromise;
await UrlbarTestUtils.assertSearchMode(window, {
engineName: ENGINE_NAME,
engineName,
entry: "tabtosearch",
});
assertSearchModeScalar("tabtosearch", "other");
assertSearchModeScalars("tabtosearch", "other");
await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window);
@ -502,11 +538,11 @@ add_task(async function test_tabtosearch_onboard() {
UrlbarPrefs.set("tipShownCount.tabToSearch", 0);
UrlbarProviderTabToSearch.onboardingResultsThisSession = 0;
await PlacesTestUtils.addVisits([`https://${ENGINE_DOMAIN}/`]);
await PlacesTestUtils.addVisits([`http://${engineDomain}/`]);
await UrlbarTestUtils.promiseAutocompleteResultPopup({
window,
value: ENGINE_DOMAIN.slice(0, 4),
value: engineDomain.slice(0, 4),
});
let tabToSearchResult = (
await UrlbarTestUtils.waitForAutocompleteResultAt(window, 1)
@ -518,7 +554,7 @@ add_task(async function test_tabtosearch_onboard() {
);
Assert.equal(
tabToSearchResult.payload.engine,
ENGINE_NAME,
engineName,
"The tab-to-search result is for the correct engine."
);
Assert.equal(
@ -539,7 +575,7 @@ add_task(async function test_tabtosearch_onboard() {
await searchPromise;
await UrlbarTestUtils.assertSearchMode(window, {
engineName: ENGINE_NAME,
engineName,
entry: "tabtosearch_onboard",
});
@ -550,7 +586,7 @@ add_task(async function test_tabtosearch_onboard() {
"tabtosearch_onboard-shown",
1
);
assertSearchModeScalar("tabtosearch_onboard", "other");
assertSearchModeScalars("tabtosearch_onboard", "other");
await UrlbarTestUtils.exitSearchMode(window);
await UrlbarTestUtils.promisePopupClose(window);

Просмотреть файл

@ -0,0 +1,73 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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/.
*/
/**
* PathUtils is a set of utilities for operating on absolute paths.
*/
[ChromeOnly, Exposed=(Window, Worker)]
namespace PathUtils {
/**
* Return the last path component.
*
* @param path An absolute path.
*
* @returns The last path component.
*/
[Throws]
DOMString filename(DOMString path);
/**
* Return the parent directory name of the given path.
*
* @param path An absolute path.
*
* @return The parent directory.
*
* If the path provided is a root path (e.g., `C:` on Windows or `/`
* on *NIX), then null is returned.
*/
[Throws]
DOMString? parent(DOMString path);
/**
* Join the given components into a full path.
*
* @param components The path components. The first component must be an
* absolute path.
*/
[Throws]
DOMString join(DOMString... components);
/**
* Normalize a path by removing multiple separators and `..` and `.`
* directories.
*
* On UNIX platforms, the path must exist as symbolic links will be resolved.
*
* @param path The absolute path to normalize.
*
*/
[Throws]
DOMString normalize(DOMString path);
/**
* Split a path into its components.
*
* @param path An absolute path.
*/
[Throws]
sequence<DOMString> split(DOMString path);
/**
* Transform a file path into a file: URI
*
* @param path An absolute path.
*
* @return The file: URI as a string.
*/
[Throws]
UTF8String toFileURI(DOMString path);
};

Просмотреть файл

@ -65,6 +65,7 @@ WEBIDL_FILES = [
"MozStorageAsyncStatementParams.webidl",
"MozStorageStatementParams.webidl",
"MozStorageStatementRow.webidl",
"PathUtils.webidl",
"PrecompiledScript.webidl",
"PromiseDebugging.webidl",
"SessionStoreUtils.webidl",

242
dom/system/PathUtils.cpp Normal file
Просмотреть файл

@ -0,0 +1,242 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* 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 "PathUtils.h"
#include "mozilla/ErrorNames.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Span.h"
#include "mozilla/dom/DOMParser.h"
#include "mozilla/dom/PathUtilsBinding.h"
#include "nsIFile.h"
#include "nsLocalFile.h"
#include "nsNetUtil.h"
#include "nsString.h"
namespace mozilla {
namespace dom {
static constexpr auto ERROR_EMPTY_PATH =
"PathUtils does not support empty paths"_ns;
static constexpr auto ERROR_INITIALIZE_PATH = "Could not initialize path"_ns;
static constexpr auto ERROR_GET_PARENT = "Could not get parent path"_ns;
static void ThrowError(ErrorResult& aErr, const nsresult aResult,
const nsCString& aMessage) {
nsAutoCStringN<32> errName;
GetErrorName(aResult, errName);
nsAutoCStringN<256> formattedMsg;
formattedMsg.Append(aMessage);
formattedMsg.Append(": "_ns);
formattedMsg.Append(errName);
switch (aResult) {
case NS_ERROR_FILE_UNRECOGNIZED_PATH:
aErr.ThrowOperationError(formattedMsg);
break;
case NS_ERROR_FILE_ACCESS_DENIED:
aErr.ThrowInvalidAccessError(formattedMsg);
break;
case NS_ERROR_FAILURE:
default:
aErr.ThrowUnknownError(formattedMsg);
break;
}
}
/**
* Return the leaf name, including leading path separators in the case of
* Windows UNC drive paths.
*
* @param aFile The file whose leaf name is to be returned.
* @param aResult The string to hold the resulting leaf name.
* @param aParent The pre-computed parent of |aFile|. If not provided, it will
* be computed.
*/
static nsresult GetLeafNamePreservingRoot(nsIFile* aFile, nsString& aResult,
nsIFile* aParent = nullptr) {
MOZ_ASSERT(aFile);
nsCOMPtr<nsIFile> parent = aParent;
if (!parent) {
MOZ_TRY(aFile->GetParent(getter_AddRefs(parent)));
}
if (parent) {
return aFile->GetLeafName(aResult);
}
// We have reached the root path. On Windows, the leafname for a UNC path
// will not have the leading backslashes, so we need to use the entire path
// here:
//
// * for a UNIX root path (/) this will be /;
// * for a Windows drive path (e.g., C:), this will be the drive path (C:);
// and
// * for a Windows UNC server path (e.g., \\\\server), this will be the full
// server path (\\\\server).
return aFile->GetPath(aResult);
}
void PathUtils::Filename(const GlobalObject&, const nsAString& aPath,
nsString& aResult, ErrorResult& aErr) {
if (aPath.IsEmpty()) {
aErr.ThrowNotAllowedError("PathUtils does not support empty paths");
return;
}
nsCOMPtr<nsIFile> path = new nsLocalFile();
if (nsresult rv = path->InitWithPath(aPath); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_INITIALIZE_PATH);
return;
}
if (nsresult rv = GetLeafNamePreservingRoot(path, aResult); NS_FAILED(rv)) {
ThrowError(aErr, rv, "Could not get leaf name of path"_ns);
return;
}
}
void PathUtils::Parent(const GlobalObject&, const nsAString& aPath,
nsString& aResult, ErrorResult& aErr) {
if (aPath.IsEmpty()) {
aErr.ThrowNotAllowedError(ERROR_EMPTY_PATH);
return;
}
nsCOMPtr<nsIFile> path = new nsLocalFile();
if (nsresult rv = path->InitWithPath(aPath); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_INITIALIZE_PATH);
return;
}
nsCOMPtr<nsIFile> parent;
if (nsresult rv = path->GetParent(getter_AddRefs(parent)); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_GET_PARENT);
return;
}
if (parent) {
MOZ_ALWAYS_SUCCEEDS(parent->GetPath(aResult));
} else {
aResult = VoidString();
}
}
void PathUtils::Join(const GlobalObject&, const Sequence<nsString>& aComponents,
nsString& aResult, ErrorResult& aErr) {
if (aComponents.IsEmpty()) {
return;
}
if (aComponents[0].IsEmpty()) {
aErr.ThrowNotAllowedError(ERROR_EMPTY_PATH);
return;
}
nsCOMPtr<nsIFile> path = new nsLocalFile();
if (nsresult rv = path->InitWithPath(aComponents[0]); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_INITIALIZE_PATH);
return;
}
const auto components = Span<const nsString>(aComponents).Subspan(1);
for (const auto& component : components) {
if (nsresult rv = path->Append(component); NS_FAILED(rv)) {
ThrowError(aErr, rv, "Could not append to path"_ns);
return;
}
}
MOZ_ALWAYS_SUCCEEDS(path->GetPath(aResult));
}
void PathUtils::Normalize(const GlobalObject&, const nsAString& aPath,
nsString& aResult, ErrorResult& aErr) {
if (aPath.IsEmpty()) {
aErr.ThrowNotAllowedError(ERROR_EMPTY_PATH);
return;
}
nsCOMPtr<nsIFile> path = new nsLocalFile();
if (nsresult rv = path->InitWithPath(aPath); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_INITIALIZE_PATH);
return;
}
if (nsresult rv = path->Normalize(); NS_FAILED(rv)) {
ThrowError(aErr, rv, "Could not normalize path"_ns);
return;
}
MOZ_ALWAYS_SUCCEEDS(path->GetPath(aResult));
}
void PathUtils::Split(const GlobalObject&, const nsAString& aPath,
nsTArray<nsString>& aResult, ErrorResult& aErr) {
if (aPath.IsEmpty()) {
aErr.ThrowNotAllowedError(ERROR_EMPTY_PATH);
return;
}
nsCOMPtr<nsIFile> path = new nsLocalFile();
if (nsresult rv = path->InitWithPath(aPath); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_INITIALIZE_PATH);
return;
}
while (path) {
auto* component = aResult.EmplaceBack(fallible);
if (!component) {
aErr.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
nsCOMPtr<nsIFile> parent;
if (nsresult rv = path->GetParent(getter_AddRefs(parent)); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_GET_PARENT);
return;
}
// GetLeafPreservingRoot cannot fail if we pass it a parent path.
MOZ_ALWAYS_SUCCEEDS(GetLeafNamePreservingRoot(path, *component, parent));
path = parent;
}
aResult.Reverse();
}
void PathUtils::ToFileURI(const GlobalObject&, const nsAString& aPath,
nsCString& aResult, ErrorResult& aErr) {
if (aPath.IsEmpty()) {
aErr.ThrowNotAllowedError(ERROR_EMPTY_PATH);
return;
}
nsCOMPtr<nsIFile> path = new nsLocalFile();
if (nsresult rv = path->InitWithPath(aPath); NS_FAILED(rv)) {
ThrowError(aErr, rv, ERROR_INITIALIZE_PATH);
return;
}
nsCOMPtr<nsIURI> uri;
if (nsresult rv = NS_NewFileURI(getter_AddRefs(uri), path); NS_FAILED(rv)) {
ThrowError(aErr, rv, "Could not initialize File URI"_ns);
return;
}
if (nsresult rv = uri->GetSpec(aResult); NS_FAILED(rv)) {
ThrowError(aErr, rv, "Could not retrieve URI spec"_ns);
return;
}
}
} // namespace dom
} // namespace mozilla

42
dom/system/PathUtils.h Normal file
Просмотреть файл

@ -0,0 +1,42 @@
/* -*- 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_PathUtils__
#define mozilla_dom_PathUtils__
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/DOMParser.h"
#include "nsString.h"
#include "nsTArray.h"
namespace mozilla {
namespace dom {
class PathUtils final {
public:
static void Filename(const GlobalObject&, const nsAString& aPath,
nsString& aResult, ErrorResult& aErr);
static void Parent(const GlobalObject&, const nsAString& aPath,
nsString& aResult, ErrorResult& aErr);
static void Join(const GlobalObject&, const Sequence<nsString>& aComponents,
nsString& aResult, ErrorResult& aErr);
static void Normalize(const GlobalObject&, const nsAString& aPath,
nsString& aResult, ErrorResult& aErr);
static void Split(const GlobalObject&, const nsAString& aPath,
nsTArray<nsString>& aResult, ErrorResult& aErr);
static void ToFileURI(const GlobalObject&, const nsAString& aPath,
nsCString& aResult, ErrorResult& aErr);
};
} // namespace dom
} // namespace mozilla
#endif // namespace mozilla_dom_PathUtils__

Просмотреть файл

@ -75,6 +75,7 @@ EXPORTS.mozilla += [
EXPORTS.mozilla.dom += [
"IOUtils.h",
"PathUtils.h",
]
UNIFIED_SOURCES += [
@ -82,6 +83,7 @@ UNIFIED_SOURCES += [
"nsDeviceSensors.cpp",
"nsOSPermissionRequestBase.cpp",
"OSFileConstants.cpp",
"PathUtils.cpp",
]
EXTRA_JS_MODULES += [

Просмотреть файл

@ -3,3 +3,4 @@ support-files =
worker_constants.js
[test_constants.xhtml]
[test_pathutils.html]

Просмотреть файл

@ -0,0 +1,364 @@
<!-- Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>PathUtils tests</title>
</head>
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script>
"use strict";
const { Assert } = ChromeUtils.import("resource://testing-common/Assert.jsm");
const { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm"
);
const UNRECOGNIZED_PATH = /Could not initialize path: NS_ERROR_FILE_UNRECOGNIZED_PATH/;
const EMPTY_PATH = /PathUtils does not support empty paths/;
add_task(function test_filename() {
Assert.throws(
() => PathUtils.filename(""),
EMPTY_PATH,
"PathUtils.filename() does not support empty paths"
);
Assert.throws(
() => PathUtils.filename("foo.txt"),
UNRECOGNIZED_PATH,
"PathUtils.filename() does not support relative paths"
);
if (Services.appinfo.OS === "WINNT") {
is(
PathUtils.filename("C:"),
"C:",
"PathUtils.filename() with a drive path"
);
is(
PathUtils.filename("C:\\"),
"C:",
"PathUtils.filename() with a drive path"
);
is(
PathUtils.filename("C:\\Windows"),
"Windows",
"PathUtils.filename() with a path with 2 components"
);
is(
PathUtils.filename("C:\\Windows\\"),
"Windows",
"PathUtils.filename() with a path with 2 components and a trailing slash"
);
is(
PathUtils.filename("C:\\Windows\\System32"),
"System32",
"PathUtils.filename() with a path with 3 components"
);
is(
PathUtils.filename("\\\\server"),
"\\\\server",
"PathUtils.filename() with a UNC server path"
);
is(
PathUtils.filename("C:\\file.dat"),
"file.dat",
"PathUtils.filename() with a file path"
);
} else {
is(
PathUtils.filename("/"),
"/",
"PathUtils.filename() with a root path"
);
is(
PathUtils.filename("/usr/"),
"usr",
"PathUtils.filename() with a non-root path"
);
is(
PathUtils.filename("/usr/lib/libfoo.so"),
"libfoo.so",
"PathUtils.filename() with a path with 3 components"
);
}
});
add_task(function test_parent() {
Assert.throws(
() => PathUtils.parent("."),
UNRECOGNIZED_PATH,
"PathUtils.parent() does not support relative paths"
);
Assert.throws(
() => PathUtils.parent(""),
EMPTY_PATH,
"PathUtils.parent() does not support empty paths"
);
if (Services.appinfo.OS === "WINNT") {
is(
PathUtils.parent("C:"),
null,
"PathUtils.parent() with a drive path"
);
is(
PathUtils.parent("\\\\server"),
null,
"PathUtils.parent() with a UNC server path"
);
is(
PathUtils.parent("\\\\server\\foo"),
"\\\\server",
"PathUtils.parent() with a UNC server path and child component"
);
} else {
is(
PathUtils.parent("/"),
null,
"PathUtils.parent() with a root path"
);
is(
PathUtils.parent("/var"),
"/",
"PathUtils.parent() with a 2 component path"
);
is(
PathUtils.parent("/var/run"),
"/var",
"PathUtils.parent() with a 3 component path"
);
}
});
add_task(function test_join() {
is(
PathUtils.join(),
"",
"PathUtils.join() with an empty sequence"
);
Assert.throws(
() => PathUtils.join(""),
EMPTY_PATH,
"PathUtils.join() does not support empty paths"
);
Assert.throws(
() => PathUtils.join("foo", "bar"),
UNRECOGNIZED_PATH,
"PathUtils.join() does not support relative paths"
);
Assert.throws(
() => PathUtils.join("."),
UNRECOGNIZED_PATH,
"PathUtils.join() does not support relative paths"
);
if (Services.appinfo.OS === "WINNT") {
is(
PathUtils.join("C:"),
"C:",
"PathUtils.join() with a single path"
);
is(
PathUtils.join("C:\\Windows", "System32"),
"C:\\Windows\\System32",
"PathUtils.join() with a 2 component path and an additional component"
);
is(
PathUtils.join("C:", "Users", "Example"),
"C:\\Users\\Example",
"PathUtils.join() with a root path and two additional components"
);
is(
PathUtils.join("\\\\server", "Files", "Example.dat"),
"\\\\server\\Files\\Example.dat",
"PathUtils.join() with a server path"
);
} else {
is(
PathUtils.join("/"),
"/",
"PathUtils.join() with a root path"
);
is(
PathUtils.join("/usr", "lib"),
"/usr/lib",
"PathUtils.join() with a 2 component path and an additional component"
);
is(
PathUtils.join("/", "home", "example"),
"/home/example",
"PathUtils.join() with a root path and two additional components"
);
}
});
add_task(async function test_normalize() {
Assert.throws(
() => PathUtils.normalize(""),
EMPTY_PATH,
"PathUtils.normalize() does not support empty paths"
);
Assert.throws(
() => PathUtils.normalize("."),
UNRECOGNIZED_PATH,
"PathUtils.normalize() does not support relative paths"
);
if (Services.appinfo.OS === "WINNT") {
is(
PathUtils.normalize("C:\\\\Windows\\\\..\\\\\\.\\Users\\..\\Windows"),
"C:\\Windows",
"PathUtils.normalize() with a non-normalized path"
);
} else {
// nsLocalFileUnix::Normalize() calls realpath, which resolves symlinks
// and requires the file to exist.
//
// On Darwin, the temp directory is located in `/private/var`, which is a
// symlink to `/var`, so we need to pre-normalize our temporary directory
// or expected paths won't match.
const tmpDir = PathUtils.join(
PathUtils.normalize(Services.dirsvc.get("TmpD", Ci.nsIFile).path),
"pathutils_test"
);
await IOUtils.makeDirectory(tmpDir, { ignoreExisting: true });
info(`created tmpDir ${tmpDir}`);
SimpleTest.registerCleanupFunction(async () => {
await IOUtils.remove(tmpDir, {
recursive: true,
});
});
await IOUtils.makeDirectory(PathUtils.join(tmpDir, "foo", "bar"), {
createAncestors: true,
});
is(
PathUtils.normalize("/"),
"/",
"PathUtils.normalize() with a normalized path"
);
is(
PathUtils.normalize(
PathUtils.join(
tmpDir,
"foo",
".",
"..",
"foo",
".",
"bar",
"..",
"bar"
)
),
PathUtils.join(tmpDir, "foo", "bar"),
"PathUtils.normalize() with a non-normalized path"
);
}
});
add_task(function test_split() {
Assert.throws(
() => PathUtils.split("foo"),
UNRECOGNIZED_PATH,
"PathUtils.split() does not support relative paths"
);
Assert.throws(
() => PathUtils.split(""),
EMPTY_PATH,
"PathUtils.split() does not support empty paths"
);
if (Services.appinfo.OS === "WINNT") {
Assert.deepEqual(
PathUtils.split("C:\\Users\\Example"),
["C:", "Users", "Example"],
"PathUtils.split() on an absolute path"
);
Assert.deepEqual(
PathUtils.split("C:\\Users\\Example\\"),
["C:", "Users", "Example"],
"PathUtils.split() on an absolute path with a trailing slash"
);
Assert.deepEqual(
PathUtils.split("\\\\server\\Files\\Example.dat"),
["\\\\server", "Files", "Example.dat"],
"PathUtils.split() with a server as the root"
);
} else {
Assert.deepEqual(
PathUtils.split("/home/foo"),
["/", "home", "foo"],
"PathUtils.split() on absolute path"
);
Assert.deepEqual(
PathUtils.split("/home/foo/"),
["/", "home", "foo"],
"PathUtils.split() on absolute path with trailing slash"
);
}
});
add_task(function test_toFileURI() {
Assert.throws(
() => PathUtils.toFileURI("."),
UNRECOGNIZED_PATH,
"PathUtils.toFileURI() does not support relative paths"
);
Assert.throws(
() => PathUtils.toFileURI(""),
EMPTY_PATH,
"Pathutils.toFileURI() does not support empty paths"
);
if (Services.appinfo.OS === "WINNT") {
is(
PathUtils.toFileURI("C:\\"),
"file:///C:/",
"PathUtils.toFileURI() with a root path"
);
is(
PathUtils.toFileURI("C:\\Windows\\"),
"file:///C:/Windows/",
"PathUtils.toFileURI() with a non-root directory path"
);
is(
PathUtils.toFileURI("C:\\Windows\\system32\\notepad.exe"),
"file:///C:/Windows/system32/notepad.exe",
"PathUtils.toFileURI() with a file path"
);
} else {
is(
PathUtils.toFileURI("/"),
"file:///",
"PathUtils.toFileURI() with a root path"
);
is(
PathUtils.toFileURI("/bin"),
"file:///bin/",
"PathUtils.toFileURI() with a non-root directory path"
);
is(
PathUtils.toFileURI("/bin/ls"),
"file:///bin/ls",
"PathUtils.toFileURI() with a file path"
);
}
});
</script>
<body>
</body>
</html>

Просмотреть файл

@ -0,0 +1,15 @@
<script>
function go() {
b.appendChild(document.body.firstChild)
document.getSelection().setBaseAndExtent(c.appendChild(b),0,b,1)
a.addEventListener("DOMCharacterDataModified", function() {
window.getSelection().removeAllRanges()
})
document.execCommand("delete", false)
}
</script>
<body onload=go()>
<audio id="a">
<li contenteditable="true">
<data id="c">
<source id="b">

Просмотреть файл

@ -118,6 +118,7 @@ load 1547897.html
load 1547898.html
load 1556799.html
load 1574544.html
load 1578916.html
load 1581246.html
load 1596516.html
load 1613521.html

Просмотреть файл

@ -1927,6 +1927,8 @@ bool BuildLayer(nsDisplayItem* aItem, BlobItemData* aData,
RefPtr<Layer> root = aItem->AsPaintedDisplayItem()->BuildLayer(
aDisplayListBuilder, blm, param);
aDisplayListBuilder->NotifyAndClearScrollFrames();
if (root) {
blm->SetRoot(root);
layerBuilder->WillEndTransaction();
@ -1969,6 +1971,8 @@ static bool PaintByLayer(nsDisplayItem* aItem,
RefPtr<Layer> root = aItem->AsPaintedDisplayItem()->BuildLayer(
aDisplayListBuilder, aManager, param);
aDisplayListBuilder->NotifyAndClearScrollFrames();
if (root) {
aManager->SetRoot(root);
layerBuilder->WillEndTransaction();

Просмотреть файл

@ -1643,7 +1643,6 @@ class ContainerState {
CachedScrollMetadata() : mASR(nullptr), mClip(nullptr) {}
};
CachedScrollMetadata mCachedScrollMetadata;
std::unordered_set<nsIScrollableFrame*> mScrollFramesToNotify;
};
class FLBDisplayListIterator : public FlattenedDisplayListIterator {
@ -5776,7 +5775,7 @@ void ContainerState::SetupScrollingMetadata(NewLayerEntry* aEntry) {
metadata = scrollFrame->ComputeScrollMetadata(aEntry->mLayer->Manager(),
mContainerReferenceFrame,
Some(mParameters), clip);
mScrollFramesToNotify.insert(scrollFrame);
mBuilder->AddScrollFrameToNotify(scrollFrame);
mCachedScrollMetadata.mASR = asr;
mCachedScrollMetadata.mClip = clip;
mCachedScrollMetadata.mMetadata = metadata;
@ -5908,11 +5907,6 @@ void ContainerState::PostprocessRetainedLayers(
*aOpaqueRegionForContainer,
opaqueRegions[opaqueRegionForContainer].mOpaqueRegion);
}
for (const auto& it : mScrollFramesToNotify) {
it->NotifyApzTransaction();
}
mScrollFramesToNotify.clear();
}
void ContainerState::Finish(uint32_t* aTextContentFlags,

Просмотреть файл

@ -883,6 +883,18 @@ bool nsDisplayListBuilder::ShouldRebuildDisplayListDueToPrefChange() {
return false;
}
void nsDisplayListBuilder::AddScrollFrameToNotify(
nsIScrollableFrame* aScrollFrame) {
mScrollFramesToNotify.insert(aScrollFrame);
}
void nsDisplayListBuilder::NotifyAndClearScrollFrames() {
for (const auto& it : mScrollFramesToNotify) {
it->NotifyApzTransaction();
}
mScrollFramesToNotify.clear();
}
bool nsDisplayListBuilder::MarkOutOfFlowFrameForDisplay(
nsIFrame* aDirtyFrame, nsIFrame* aFrame, const nsRect& aVisibleRect,
const nsRect& aDirtyRect) {
@ -2344,6 +2356,8 @@ FrameLayerBuilder* nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder,
frame, nullptr, this,
containerParameters, nullptr);
aBuilder->NotifyAndClearScrollFrames();
if (!record.GetStart().IsNull() &&
StaticPrefs::layers_acceleration_draw_fps()) {
if (PaintTiming* pt =

Просмотреть файл

@ -1832,6 +1832,9 @@ class nsDisplayListBuilder {
}
};
void AddScrollFrameToNotify(nsIScrollableFrame* aScrollFrame);
void NotifyAndClearScrollFrames();
private:
bool MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame, nsIFrame* aFrame,
const nsRect& aVisibleRect,
@ -2010,6 +2013,7 @@ class nsDisplayListBuilder {
// When we are inside a filter, the current ASR at the time we entered the
// filter. Otherwise nullptr.
const ActiveScrolledRoot* mFilterASR;
std::unordered_set<nsIScrollableFrame*> mScrollFramesToNotify;
bool mContainsBlendMode;
bool mIsBuildingScrollbar;
bool mCurrentScrollbarWillHaveLayer;

Просмотреть файл

@ -8,11 +8,14 @@
namespace mozilla::baseprofiler {
UniqueJSONStrings::UniqueJSONStrings() { mStringTableWriter.StartBareList(); }
UniqueJSONStrings::UniqueJSONStrings(JSONWriter::CollectionStyle aStyle) {
mStringTableWriter.StartBareList(aStyle);
}
UniqueJSONStrings::UniqueJSONStrings(const UniqueJSONStrings& aOther) {
mStringTableWriter.StartBareList();
uint32_t count = mStringHashToIndexMap.count();
UniqueJSONStrings::UniqueJSONStrings(const UniqueJSONStrings& aOther,
JSONWriter::CollectionStyle aStyle) {
mStringTableWriter.StartBareList(aStyle);
uint32_t count = aOther.mStringHashToIndexMap.count();
if (count != 0) {
MOZ_RELEASE_ASSERT(mStringHashToIndexMap.reserve(count));
for (auto iter = aOther.mStringHashToIndexMap.iter(); !iter.done();

Просмотреть файл

@ -297,10 +297,13 @@ class JSONSchemaWriter {
class UniqueJSONStrings {
public:
// Start an empty list of unique strings.
MFBT_API UniqueJSONStrings();
MFBT_API explicit UniqueJSONStrings(
JSONWriter::CollectionStyle aStyle = JSONWriter::MultiLineStyle);
// Start with a copy of the strings from another list.
MFBT_API explicit UniqueJSONStrings(const UniqueJSONStrings& aOther);
MFBT_API explicit UniqueJSONStrings(
const UniqueJSONStrings& aOther,
JSONWriter::CollectionStyle aStyle = JSONWriter::MultiLineStyle);
MFBT_API ~UniqueJSONStrings();

Просмотреть файл

@ -3555,6 +3555,192 @@ void TestProfiler() {
printf("TestProfiler done\n");
}
// Minimal string escaping, similar to how C++ stringliterals should be entered,
// to help update comparison strings in tests below.
void printEscaped(std::string_view aString) {
for (const char c : aString) {
switch (c) {
case '\n':
fprintf(stderr, "\\n\n");
break;
case '"':
fprintf(stderr, "\\\"");
break;
case '\\':
fprintf(stderr, "\\\\");
break;
default:
if (c >= ' ' && c <= '~') {
fprintf(stderr, "%c", c);
} else {
fprintf(stderr, "\\x%02x", unsigned(c));
}
break;
}
}
}
// Run aF(SpliceableChunkedJSONWriter&, UniqueJSONStrings&) from inside a JSON
// array, then output the string table, and compare the full output to
// aExpected.
template <typename F>
static void VerifyUniqueStringContents(
F&& aF, std::string_view aExpectedData,
std::string_view aExpectedUniqueStrings,
mozilla::baseprofiler::UniqueJSONStrings* aUniqueStringsOrNull = nullptr) {
mozilla::baseprofiler::SpliceableChunkedJSONWriter writer;
// By default use a local UniqueJSONStrings, otherwise use the one provided.
mozilla::baseprofiler::UniqueJSONStrings localUniqueStrings(
mozilla::JSONWriter::SingleLineStyle);
mozilla::baseprofiler::UniqueJSONStrings& uniqueStrings =
aUniqueStringsOrNull ? *aUniqueStringsOrNull : localUniqueStrings;
writer.Start(mozilla::JSONWriter::SingleLineStyle);
{
writer.StartArrayProperty("data", mozilla::JSONWriter::SingleLineStyle);
{ std::forward<F>(aF)(writer, uniqueStrings); }
writer.EndArray();
writer.StartArrayProperty("stringTable",
mozilla::JSONWriter::SingleLineStyle);
{ uniqueStrings.SpliceStringTableElements(writer); }
writer.EndArray();
}
writer.End();
UniquePtr<char[]> jsonString = writer.ChunkedWriteFunc().CopyData();
MOZ_RELEASE_ASSERT(jsonString);
std::string_view jsonStringView(jsonString.get());
std::string expected = "{\"data\": [";
expected += aExpectedData;
expected += "], \"stringTable\": [";
expected += aExpectedUniqueStrings;
expected += "]}\n";
if (jsonStringView != expected) {
fprintf(stderr,
"Expected:\n"
"------\n");
printEscaped(expected);
fprintf(stderr,
"\n"
"------\n"
"Actual:\n"
"------\n");
printEscaped(jsonStringView);
fprintf(stderr,
"\n"
"------\n");
}
MOZ_RELEASE_ASSERT(jsonStringView == expected);
}
void TestUniqueJSONStrings() {
printf("TestUniqueJSONStrings...\n");
using SCJW = mozilla::baseprofiler::SpliceableChunkedJSONWriter;
using UJS = mozilla::baseprofiler::UniqueJSONStrings;
// Empty everything.
VerifyUniqueStringContents([](SCJW& aWriter, UJS& aUniqueStrings) {}, "", "");
// Empty unique strings.
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aWriter.StringElement("string");
},
R"("string")", "");
// One unique string.
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aUniqueStrings.WriteElement(aWriter, "string");
},
"0", R"("string")");
// One unique string twice.
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aUniqueStrings.WriteElement(aWriter, "string");
aUniqueStrings.WriteElement(aWriter, "string");
},
"0, 0", R"("string")");
// Two single unique strings.
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aUniqueStrings.WriteElement(aWriter, "string0");
aUniqueStrings.WriteElement(aWriter, "string1");
},
"0, 1", R"("string0", "string1")");
// Two unique strings with repetition.
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aUniqueStrings.WriteElement(aWriter, "string0");
aUniqueStrings.WriteElement(aWriter, "string1");
aUniqueStrings.WriteElement(aWriter, "string0");
},
"0, 1, 0", R"("string0", "string1")");
// Mix some object properties, for coverage.
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aUniqueStrings.WriteElement(aWriter, "string0");
aWriter.StartObjectElement(mozilla::JSONWriter::SingleLineStyle);
{
aUniqueStrings.WriteProperty(aWriter, "p0", "prop");
aUniqueStrings.WriteProperty(aWriter, "p1", "string0");
aUniqueStrings.WriteProperty(aWriter, "p2", "prop");
}
aWriter.EndObject();
aUniqueStrings.WriteElement(aWriter, "string1");
aUniqueStrings.WriteElement(aWriter, "string0");
aUniqueStrings.WriteElement(aWriter, "prop");
},
R"(0, {"p0": 1, "p1": 0, "p2": 1}, 2, 0, 1)",
R"("string0", "prop", "string1")");
// Unique string table with pre-existing data.
{
UJS ujs(mozilla::JSONWriter::SingleLineStyle);
{
SCJW writer;
ujs.WriteElement(writer, "external0");
ujs.WriteElement(writer, "external1");
ujs.WriteElement(writer, "external0");
}
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aUniqueStrings.WriteElement(aWriter, "string0");
aUniqueStrings.WriteElement(aWriter, "string1");
aUniqueStrings.WriteElement(aWriter, "string0");
},
"2, 3, 2", R"("external0", "external1", "string0", "string1")", &ujs);
}
// Unique string table with pre-existing data from another table.
{
UJS ujs(mozilla::JSONWriter::SingleLineStyle);
{
SCJW writer;
ujs.WriteElement(writer, "external0");
ujs.WriteElement(writer, "external1");
ujs.WriteElement(writer, "external0");
}
UJS ujsCopy(ujs, mozilla::JSONWriter::SingleLineStyle);
VerifyUniqueStringContents(
[](SCJW& aWriter, UJS& aUniqueStrings) {
aUniqueStrings.WriteElement(aWriter, "string0");
aUniqueStrings.WriteElement(aWriter, "string1");
aUniqueStrings.WriteElement(aWriter, "string0");
},
"2, 3, 2", R"("external0", "external1", "string0", "string1")", &ujs);
}
printf("TestUniqueJSONStrings done\n");
}
void StreamMarkers(const mozilla::ProfileChunkedBuffer& aBuffer,
mozilla::JSONWriter& aWriter) {
aWriter.Start();
@ -3872,6 +4058,7 @@ void TestProfilerMarkers() {
mozilla::baseprofiler::profiler_current_thread_id());
// ::SleepMilli(10000);
TestUniqueJSONStrings();
TestMarkerCategory();
TestMarkerThreadId();
TestMarkerNoPayload();

Просмотреть файл

@ -195,11 +195,9 @@ class MozbuildObject(ProcessExecutionMixin):
if detect_virtualenv_mozinfo and os.path.isfile(mozinfo_path):
topsrcdir, topobjdir, mozconfig = load_mozinfo(mozinfo_path)
# If we were successful, we're only guaranteed to find a topsrcdir. If
# we couldn't find that, there's nothing we can do.
if not topsrcdir:
raise BuildEnvironmentNotFoundException(
"Could not find Mozilla source tree or build environment."
topsrcdir = os.path.abspath(
os.path.join(os.path.dirname(__file__), "..", "..", "..")
)
topsrcdir = mozpath.normsep(topsrcdir)

Просмотреть файл

@ -1114,6 +1114,9 @@ def _get_desktop_run_parser():
"being used.",
)
group.add_argument("--packaged", action="store_true", help="Run a packaged build.")
group.add_argument(
"--app", help="Path to executable to run (default: output of ./mach build)"
)
group.add_argument(
"--remote",
"-r",
@ -1418,6 +1421,7 @@ class RunProgram(MachCommandBase):
self,
params,
packaged,
app,
remote,
background,
noprofile,
@ -1441,7 +1445,7 @@ class RunProgram(MachCommandBase):
if packaged:
binpath = self.get_binary_path(where="staged-package")
else:
binpath = self.get_binary_path("app")
binpath = app or self.get_binary_path("app")
except BinaryNotFoundException as e:
self.log(logging.ERROR, "run", {"error": str(e)}, "ERROR: {error}")
if packaged:

Просмотреть файл

@ -1 +1 @@
035110dfa0b9
97751cd6d553

Просмотреть файл

@ -10,3 +10,4 @@
*/
#error "Do not include this header file."

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,161 +0,0 @@
/* vim: set ts=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 hkdf_vectors_h__
#define hkdf_vectors_h__
#include <vector>
typedef struct hkdf_result_str {
SECStatus expect_rv;
bool output_match;
} hkdf_result;
typedef struct hkdf_vector_str {
uint32_t test_id;
CK_MECHANISM_TYPE mech;
size_t l;
std::vector<uint8_t> ikm;
std::vector<uint8_t> salt;
std::vector<uint8_t> info;
std::vector<uint8_t> okm;
hkdf_result res;
} hkdf_vector;
// Vectors sourced from https://tools.ietf.org/html/rfc5869
// Test IDs correspond to those in Appendix A.
const hkdf_vector kHkdfTestVectors[] = {
{1,
CKM_NSS_HKDF_SHA256,
42,
{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c},
{0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9},
{0x3c, 0xb2, 0x5f, 0x25, 0xfa, 0xac, 0xd5, 0x7a, 0x90, 0x43, 0x4f,
0x64, 0xd0, 0x36, 0x2f, 0x2a, 0x2d, 0x2d, 0x0a, 0x90, 0xcf, 0x1a,
0x5a, 0x4c, 0x5d, 0xb0, 0x2d, 0x56, 0xec, 0xc4, 0xc5, 0xbf, 0x34,
0x00, 0x72, 0x08, 0xd5, 0xb8, 0x87, 0x18, 0x58, 0x65},
{SECSuccess, true}},
{2,
CKM_NSS_HKDF_SHA256,
82,
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f},
{0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83,
0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf},
{0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb,
0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3,
0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff},
{0xb1, 0x1e, 0x39, 0x8d, 0xc8, 0x03, 0x27, 0xa1, 0xc8, 0xe7, 0xf7, 0x8c,
0x59, 0x6a, 0x49, 0x34, 0x4f, 0x01, 0x2e, 0xda, 0x2d, 0x4e, 0xfa, 0xd8,
0xa0, 0x50, 0xcc, 0x4c, 0x19, 0xaf, 0xa9, 0x7c, 0x59, 0x04, 0x5a, 0x99,
0xca, 0xc7, 0x82, 0x72, 0x71, 0xcb, 0x41, 0xc6, 0x5e, 0x59, 0x0e, 0x09,
0xda, 0x32, 0x75, 0x60, 0x0c, 0x2f, 0x09, 0xb8, 0x36, 0x77, 0x93, 0xa9,
0xac, 0xa3, 0xdb, 0x71, 0xcc, 0x30, 0xc5, 0x81, 0x79, 0xec, 0x3e, 0x87,
0xc1, 0x4c, 0x01, 0xd5, 0xc1, 0xf3, 0x43, 0x4f, 0x1d, 0x87},
{SECSuccess, true}},
{3,
CKM_NSS_HKDF_SHA256,
42,
{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b},
{},
{},
{0x8d, 0xa4, 0xe7, 0x75, 0xa5, 0x63, 0xc1, 0x8f, 0x71, 0x5f, 0x80,
0x2a, 0x06, 0x3c, 0x5a, 0x31, 0xb8, 0xa1, 0x1f, 0x5c, 0x5e, 0xe1,
0x87, 0x9e, 0xc3, 0x45, 0x4e, 0x5f, 0x3c, 0x73, 0x8d, 0x2d, 0x9d,
0x20, 0x13, 0x95, 0xfa, 0xa4, 0xb6, 0x1a, 0x96, 0xc8},
{SECSuccess, true}},
{4,
CKM_NSS_HKDF_SHA1,
42,
{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b},
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c},
{0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9},
{0x08, 0x5a, 0x01, 0xea, 0x1b, 0x10, 0xf3, 0x69, 0x33, 0x06, 0x8b,
0x56, 0xef, 0xa5, 0xad, 0x81, 0xa4, 0xf1, 0x4b, 0x82, 0x2f, 0x5b,
0x09, 0x15, 0x68, 0xa9, 0xcd, 0xd4, 0xf1, 0x55, 0xfd, 0xa2, 0xc2,
0x2e, 0x42, 0x24, 0x78, 0xd3, 0x05, 0xf3, 0xf8, 0x96},
{SECSuccess, true}},
{5,
CKM_NSS_HKDF_SHA1,
82,
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f},
{0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83,
0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf},
{0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb,
0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3,
0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff},
{0x0b, 0xd7, 0x70, 0xa7, 0x4d, 0x11, 0x60, 0xf7, 0xc9, 0xf1, 0x2c, 0xd5,
0x91, 0x2a, 0x06, 0xeb, 0xff, 0x6a, 0xdc, 0xae, 0x89, 0x9d, 0x92, 0x19,
0x1f, 0xe4, 0x30, 0x56, 0x73, 0xba, 0x2f, 0xfe, 0x8f, 0xa3, 0xf1, 0xa4,
0xe5, 0xad, 0x79, 0xf3, 0xf3, 0x34, 0xb3, 0xb2, 0x02, 0xb2, 0x17, 0x3c,
0x48, 0x6e, 0xa3, 0x7c, 0xe3, 0xd3, 0x97, 0xed, 0x03, 0x4c, 0x7f, 0x9d,
0xfe, 0xb1, 0x5c, 0x5e, 0x92, 0x73, 0x36, 0xd0, 0x44, 0x1f, 0x4c, 0x43,
0x00, 0xe2, 0xcf, 0xf0, 0xd0, 0x90, 0x0b, 0x52, 0xd3, 0xb4},
{SECSuccess, true}},
{6,
CKM_NSS_HKDF_SHA1,
42,
{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b},
{},
{},
{0x0a, 0xc1, 0xaf, 0x70, 0x02, 0xb3, 0xd7, 0x61, 0xd1, 0xe5, 0x52,
0x98, 0xda, 0x9d, 0x05, 0x06, 0xb9, 0xae, 0x52, 0x05, 0x72, 0x20,
0xa3, 0x06, 0xe0, 0x7b, 0x6b, 0x87, 0xe8, 0xdf, 0x21, 0xd0, 0xea,
0x00, 0x03, 0x3d, 0xe0, 0x39, 0x84, 0xd3, 0x49, 0x18},
{SECSuccess, true}},
{7,
CKM_NSS_HKDF_SHA1,
42,
{0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c},
{},
{},
{0x2c, 0x91, 0x11, 0x72, 0x04, 0xd7, 0x45, 0xf3, 0x50, 0x0d, 0x63,
0x6a, 0x62, 0xf6, 0x4f, 0x0a, 0xb3, 0xba, 0xe5, 0x48, 0xaa, 0x53,
0xd4, 0x23, 0xb0, 0xd1, 0xf2, 0x7e, 0xbb, 0xa6, 0xf5, 0xe5, 0x67,
0x3a, 0x08, 0x1d, 0x70, 0xcc, 0xe7, 0xac, 0xfc, 0x48},
{SECSuccess, true}}};
#endif // hkdf_vectors_h__

Просмотреть файл

@ -0,0 +1,841 @@
/* vim: set ts=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/. */
/* This file is generated from sources in nss/gtests/common/wycheproof
* automatically and should not be touched manually.
* Generation is trigged by calling python3 genTestVectors.py */
#ifndef hmac_sha256_vectors_h__
#define hmac_sha256_vectors_h__
#include "testvectors_base/test-structs.h"
const HmacTestVector kHmacSha256WycheproofVectors[] = {
{1, "empty message",
"1e225cafb90339bba1b24076d4206c3e79c355805d851682bc818baa4f5a7779", "",
"b175b57d89ea6cb606fb3363f2538abd73a4c00b4a1386905bac809004cf1933", false},
{2, "short message",
"8159fd15133cd964c9a6964c94f0ea269a806fd9f43f0da58b6cd1b33d189b2a", "77",
"dfc5105d5eecf7ae7b8b8de3930e7659e84c4172f2555142f1e568fc1872ad93", false},
{3, "short message",
"85a7cbaae825bb82c9b6f6c5c2af5ac03d1f6daa63d2a93c189948ec41b9ded9", "a59b",
"0fe2f13bba2198f6dda1a084be928e304e9cb16a56bc0b7b939a073280244373", false},
{4, "short message",
"48f3029334e55cfbd574ccc765fb2c3685aab1f4837d23370874a3e634c3a76d",
"c7b8b2",
"6c13f79bb2d5b6f9a315fe8fd6cbb5cb817a660687009deccd88c377429e596d", false},
{5, "short message",
"de8b5b5b2f09645be47ecb6407a4e1d9c6b33ae3c2d22517d3357da0357a3139",
"cc021d65",
"e87538eb167e62d7cb236690ff3f034a9c12d417aa8dfa694d7405f9e1f85fe8", false},
{6, "short message",
"b7938910f518f13205ca1492c669001a14ff913c8ab4a0dc3564e7418e91297c",
"a4a6ef6ebd",
"01a93f4ed216d0b280896301e366aa67b25e6b6a5a6e84f291a13391c6e496c5", false},
{7, "short message",
"1bb997ff4de8a5a391de5c08a33bc2c7c2891e47ad5b9c63110192f78b98fe78",
"667e015df7fc",
"06b5d8c5392323a802bc5cdd0b3c527454a873d9651c368836eaa4ad982ba546", false},
{8, "short message",
"32fdeda39f98b4f4426c2d2ac00ab5dd4bfabb68f311447256ed6d3d3a51b154",
"4163a9f77e41f5",
"1b0103729f48c2772bb132aef9ebd6dd6aafc9145df6d5c514b233ee92ef4a00", false},
{9, "short message",
"233e4fdee70bcc20235b6977ddfc05b0df66f5635d827c66e5a63cdb16a24938",
"fdb2ee4b6d1a0ac2",
"120b26ee1355c134c262513c7922deb6c4fd90303de4cd61b9f9cd08f22d6e18", false},
{10, "short message",
"b984c6734e0bd12b1737b2fc7a1b3803b4dfec402140a57b9eccc35414ae661b",
"dea584d0e2a14ad5fd",
"88bc2282e5fce47ec6d9895395cd47fff91a0cdc589a8fd56d8d344616533a3d", false},
{11, "short message",
"d0caf1456ac5e255fa6afd61a79dc8c716f5358a298a508271363fe1ff983561",
"18261dc806913c534666",
"f678f081d83cf126ad6bd52c2dffd786214f519c47452b85a97458d0c10c3ee5", false},
{12, "short message",
"835bc8241ed817735ec9d3d0e2df4c173ee4dded4a8ef0c04a96c48f11820463",
"26f8083e944bacf04e9a4d",
"e0e46cd7d1a75b3d102893da64def46e455308761f1d908786628ca7ee22a0eb", false},
{13, "short message",
"055f95c9461b0809575eccdfa5cdd06275f25d30915c4eb8db40e1acd3ab7591",
"bfb7d6a08dbaa5225f320887",
"e76d5c8c070a6b3c4824e9f342dc3056e63819509e1def98b585aeba0d638a00", false},
{14, "short message",
"e40f7a3eb88ddec4c6347ea4d67610756c82c8ebcc237629bf873ccabc32984a",
"7fe43febc78474649e45bf99b2",
"aa57d020aa24ad823472c2b80ff2d0cf475f7de0068f9a59e8112fede53a3581", false},
{15, "short message",
"b020ad1de1c141f7ec615ee5701521773f9b232e4d06376c382894ce51a61f48",
"81c7581a194b5e71b41146a582c1",
"f45c72603cc160c0762f703407844a7781dfe0f1ddf0aaf4ccd8205e94469aed", false},
{16, "short message",
"9f3fd61a105202648ecff6074c95e502c1c51acd32ec538a5cce89ef841f7989",
"2a76f2acdace42e3b779724946912c",
"0226ee13cc05e2340135b3f4b27a9da1a160f6170fe805dadd98a3711ec9c421", false},
{17, "", "6fa353868c82e5deeedac7f09471a61bf749ab5498239e947e012eee3c82d7c4",
"aeed3e4d4cb9bbb60d482e98c126c0f5",
"9ed7f0e73812a27a87a3808ee0c89a6456499e835974ba57c5aab2a0d8c69e93", false},
{18, "", "5300489494ca86221c91d6d953952ae1a5e097139dc9cf1179c2f56433753824",
"90fea6cf2bd811b449f333ee9233e57697",
"5b692cba13b54fffc3adcbb0e015cc011fbfd61235303ff0ad2a49775083bf22", false},
{19, "", "383e7c5c13476a62268423ef0500479f9e86e236c5a081c6449189e6afdf2af5",
"3202705af89f9555c540b0e1276911d01971abb2c35c78b2",
"4e4901592ba46476408d758435c7d1b489d2689afd84ceaaee78bfb91fd9391d", false},
{20, "", "186e248ad824e1eb93329a7fdcd565b6cb4eaf3f85b90b910777128d8c538d27",
"92ef9ff52f46eccc7e38b9ee19fd2de3b37726c8e6ce9e1b96db5dda4c317902",
"3fc1d73dd4a8858c1fc3d8c4a3f33ed5ad0c70210038394a5902cb26fe287348", false},
{21, "long message",
"28855c7efc8532d92567300933cc1ca2d0586f55dcc9f054fcca2f05254fbf7f",
"9c09207ff0e6e582cb3747dca954c94d45c05e93f1e6f21179cf0e25b4cede74b5479d32f"
"5166935c86f0441905865",
"788c0589000fb7f0b5d51f1596472bc9ec413421a43df96ee32b02b5d275ffe3", false},
{22, "long message",
"8e540cb30c94836ae2a5950f355d482a7002e255207e94fda3f7ef1a099013a0",
"d6500f95e11262e308bf3df4df4b855f33e857563d4543f195639a0a17b442eb9fdcc1367"
"d2eee75c8f805730b89290f",
"39697e70ce741feb33dedc069f00b5627fd9b837d10cbdd5b6d19cfbd511dd2c", false},
{23, "long message",
"69c50d5274358188cff4c0fae742243d4e8a5e5ba55d94ff40edd90f6a43dd10",
"1ac5255aff052828d8ea21b376f1ebdd4bb879949913900405aebce83e48feb6813b5e9c8"
"9f94501a8ade41b26b815c521",
"4b0b4d0416fa2e11586fbfa7fb11261e69991dfa34019b9893d69a2be8c1fc80", false},
{24, "long message",
"23209b7c5aadcbd13f7279af1a86d3c7ae8f179d1bcaaad0dff9a15302e78dbf",
"84bdac37e1af35d9356404e2787d47ece58348dea76a4a46e8aade3463d4db8c94a051be3"
"733b38d756984865d56c60e8025f15e3f968f093e7fb7ebc7e31189c5692d15ed4256737b"
"9b1894e5809503aaa1c9983fb096aa21916361eeb6ef455b129723a1a1ddf9deddea20852"
"9a648",
"4a85c479d1650dbd73bc5248074a55ff50218bddaa8d1fddaaf44946dc19aefb", false},
{25, "long message",
"7c9cc667cae175f448faa96647319633b2d48531373ae7d316c44ddd8b9f69cf",
"9233c1d73b498c5106ff88951e07b9652cb0ddae740737ec205c9876d094978bfc947f7dc"
"937119fd6a93915b19b625958a7a22363aa2ac33fb869ed16b303336ab740a0498a2df66a"
"6599da710094481a7b544bd955b6f97135ba4673401db2db144a6e287041e47a51ed9b6ba"
"956c13508c1c0c25310105239ab73629e30",
"ca1b80441d333909c2bb30769650055051ed20f17de8ee953cb9070af56c704f", false},
{26, "long message",
"82314540564ea3ce30591e97f68b2602de40fa29f773c2508327471b8348e8c4",
"6a6d2f45cebf2757ae16ea33c68617671d77f8fdf80bed8fc5cdc5c8b7086bd28e7eb3eec"
"c7163491104e5309455e67f836579b82a1da3bf5991a8e2b2f189a49e05700e46c409ed5d"
"e77780a5f389e3f13dad406c9d55675329c5c921f07034180937c0f6ef34a2308b6ff3e1a"
"0e9dc1ea65f5632730e8744d1db2c40a6595b",
"0900b3e6535d34f90e2c335775e86bf38ee7e3d26fb60cd9cdf639eb3496b94c", false},
{27, "long message",
"d115acc9a636915241795f48852052e07b51273ae2448251ec1d0d0f9807f3db",
"696d2456de853fa028f486fef437b6b6d1b530a8475e299db3a9005ae9cef8401985b7d31"
"e172e8f439ccd1ad1ec44c9b86b78f3f243c1305b53bc21abad7a8fc5256311bfd34c98e3"
"7dfdc649e7ae4bda08cf2994b063c0c7106ed0b02a1f48af9191cbfb0d6a953b7e04327df"
"e8c93779cb574ba9cba575d01674e83621aa0c5f400d6e6cd24b301e33c9f3303e73bf357"
"408c1be86c2489c09de998ff2ef32df554f1247d9313ce1a7160115d06f4c18d6556ff798"
"6ef8a55e2adcfa27e4c69c71cc2ff01639e9d49bd9ed0687f530ffeb0890132457df20880"
"81bc4a2f7f0a9f4dcea2c80d991db7f3747a1803d7619aaf3dd382c69536a0bcdb931cbe",
"82f92977f0b605eaada510ffceb53ad75fde16a8029f1b75b406a84270dbb8b7", false},
{28, "Flipped bit 0 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d28b42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{29, "Flipped bit 0 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d9b99f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{30, "Flipped bit 1 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d18b42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{31, "Flipped bit 1 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"dab99f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{32, "Flipped bit 7 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"538b42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{33, "Flipped bit 7 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"58b99f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{34, "Flipped bit 8 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38a42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{35, "Flipped bit 8 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b89f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{36, "Flipped bit 31 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42896d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{37, "Flipped bit 31 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99fa709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{38, "Flipped bit 32 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096c80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{39, "Flipped bit 32 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2708a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{40, "Flipped bit 33 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096f80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{41, "Flipped bit 33 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f270ba3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{42, "Flipped bit 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f4df826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{43, "Flipped bit 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3caf4172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{44, "Flipped bit 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f836b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{45, "Flipped bit 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74162cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{46, "Flipped bit 71 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f026b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{47, "Flipped bit 71 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74972cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{48, "Flipped bit 77 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f824b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{49, "Flipped bit 77 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74170cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{50, "Flipped bit 80 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b45a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{51, "Flipped bit 80 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbf93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{52, "Flipped bit 96 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d4607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{53, "Flipped bit 96 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbe93834c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{54, "Flipped bit 97 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d7607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{55, "Flipped bit 97 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbe93804c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{56, "Flipped bit 103 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a955607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{57, "Flipped bit 103 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbe93024c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{58, "Flipped bit 248 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1ca", true},
{59, "Flipped bit 248 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14f", true},
{60, "Flipped bit 249 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1c9", true},
{61, "Flipped bit 249 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14c", true},
{62, "Flipped bit 254 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc18b", true},
{63, "Flipped bit 254 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef10e", true},
{64, "Flipped bit 255 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc14b", true},
{65, "Flipped bit 255 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3ca74172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef1ce", true},
{66, "Flipped bits 0 and 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d28b42096d80f45f836b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{67, "Flipped bits 0 and 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d9b99f2709a3ca74162cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{68, "Flipped bits 31 and 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42896d80f4df826b44a9d5607de72496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{69, "Flipped bits 31 and 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99fa709a3caf4172cbe93824c1f29b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{70, "Flipped bits 63 and 127 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f4df826b44a9d5607d672496a415d3f4a1a8c88e3bb9da8dc1cb", true},
{71, "Flipped bits 63 and 127 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d8b99f2709a3caf4172cbe93824c1fa9b23a0c1e9c21bd851ff2d2c39dbef14e", true},
{72, "all bits of tag flipped",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"2c74bdf6927f0ba07d94bb562a9f8218db695bea2c0b5e573771c44625723e34", true},
{73, "all bits of tag flipped",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"274660d8f65c358be8d3416c7db3e0d64dc5f3e163de427ae00d2d3c62410eb1", true},
{74, "Tag changed to all zero",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"0000000000000000000000000000000000000000000000000000000000000000", true},
{75, "Tag changed to all zero",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"0000000000000000000000000000000000000000000000000000000000000000", true},
{76, "tag changed to all 1",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", true},
{77, "tag changed to all 1",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", true},
{78, "msbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"530bc289ed0074df02ebc42955e0fd67a416249553742128480ebb395a0d414b", true},
{79, "msbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"58391fa789234af497ac3e1302cc9fa932ba8c9e1ca13d059f7252431d3e71ce", true},
{80, "lsbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d28a43086c81f55e836a45a8d4617ce62597a514d2f5a0a9c98f3ab8db8cc0ca", true},
{81, "lsbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f",
"d9b89e2608a2cb75162dbf92834d1e28b33b0d1f9d20bc841ef3d3c29cbff04f", true},
{82, "empty message",
"7bf9e536b66a215c22233fe2daaa743a898b9acb9f7802de70b40e3d6e43ef97", "",
"f4605585949747de26f3ee98a738b172", false},
{83, "short message",
"e754076ceab3fdaf4f9bcab7d4f0df0cbbafbc87731b8f9b7cd2166472e8eebc", "40",
"0dc00d7217bbafe8d78bf961189b8fd2", false},
{84, "short message",
"ea3b016bdd387dd64d837c71683808f335dbdc53598a4ea8c5f952473fafaf5f", "6601",
"ff296b368d3bf059cc48682f6949ccaa", false},
{85, "short message",
"73d4709637857dafab6ad8b2b0a51b06524717fedf100296644f7cfdaae1805b",
"f1d300", "2d02bd1c25b1fe52b1ead07374d6e883", false},
{86, "short message",
"d5c81b399d4c0d1583a13da56de6d2dc45a66e7b47c24ab1192e246dc961dd77",
"2ae63cbf", "4d9e8bddf9b7a1218309d5988aa1b0d9", false},
{87, "short message",
"2521203fa0dddf59d837b2830f87b1aa61f958155df3ca4d1df2457cb4284dc8",
"af3a015ea1", "cb8a4b413350b42f4ac3533cc7f47864", false},
{88, "short message",
"665a02bc265a66d01775091da56726b6668bfd903cb7af66fb1b78a8a062e43c",
"3f56935def3f", "1cfce745db1ca7de9a1d4420e612ca55", false},
{89, "short message",
"facd75b22221380047305bc981f570e2a1af38928ea7e2059e3af5fc6b82b493",
"57bb86beed156f", "0bde0d0c756df09d4f6da81b299a3adf", false},
{90, "short message",
"505aa98819809ef63b9a368a1e8bc2e922da45b03ce02d9a7966b15006dba2d5",
"2e4e7ef728fe11af", "406a5c2bd3e6a9595f9b7dff608d59a7", false},
{91, "short message",
"f942093842808ba47f64e427f7351dde6b9546e66de4e7d60aa6f328182712cf",
"852a21d92848e627c7", "0b1bf9e98d0a794fa55c09b63e25799f", false},
{92, "short message",
"64be162b39c6e5f1fed9c32d9f674d9a8cde6eaa2443214d86bd4a1fb53b81b4",
"195a3b292f93baff0a2c", "71f33f6021d90858cadb1353d7fbe8d7", false},
{93, "short message",
"b259a555d44b8a20c5489e2f38392ddaa6be9e35b9833b67e1b5fdf6cb3e4c6c",
"afd73117330c6e8528a6e4", "4b8d76372ebe5e5caa56ca4e5c59cdd3", false},
{94, "short message",
"2c6fc62daa77ba8c6881b3dd6989898fef646663cc7b0a3db8228a707b85f2dc",
"0ff54d6b6759120c2e8a51e3", "c580c542846a96e84ea77701778455bf", false},
{95, "short message",
"abab815d51df29f740e4e2079fb798e0152836e6ab57d1536ae8929e52c06eb8",
"f0058d412a104e53d820b95a7f", "13cdb005059338f0f28e2d8ce1af5d0a", false},
{96, "short message",
"3d5da1af83f7287458bff7a7651ea5d8db72259401333f6b82096996dd7eaf19",
"aacc36972f183057919ff57b49e1", "bd993e4428cbc0e275e4d80b6f520363", false},
{97, "short message",
"c19bdf314c6cf64381425467f42aefa17c1cc9358be16ce31b1d214859ce86aa",
"5d066a92c300e9b6ddd63a7c13ae33", "86c9f4dde0b257a7053a7b03c7504409",
false},
{98, "", "612e837843ceae7f61d49625faa7e7494f9253e20cb3adcea686512b043936cd",
"cc37fae15f745a2f40e2c8b192f2b38d", "b96bcacafac30094f18ac5039e7b3656",
false},
{99, "", "73216fafd0022d0d6ee27198b2272578fa8f04dd9f44467fbb6437aa45641bf7",
"d5247b8f6c3edcbfb1d591d13ece23d2f5", "6e597c4c3861a380c06854b446fc2a87",
false},
{100, "",
"0427a70e257528f3ab70640bba1a5de12cf3885dd4c8e284fbbb55feb35294a5",
"13937f8544f44270d01175a011f7670e93fa6ba7ef02336e",
"f731aaf2f04023d621f10495344679a0", false},
{101, "",
"96e1e4896fb2cd05f133a6a100bc5609a7ac3ca6d81721e922dadd69ad07a892",
"91a17e4dfcc3166a1add26ff0e7c12056e8a654f28a6de24f4ba739ceb5b5b18",
"95243eb1a9d448174ae4fccf4a53ebfe", false},
{102, "long message",
"41201567be4e6ea06de2295fd0e6e8a7d862bb57311894f525d8adeabba4a3e4",
"58c8c73bdd3f350c97477816eae4d0789c9369c0e99c248902c700bc29ed986425985eb3f"
"a55709b73bf620cd9b1cb",
"343367207f71425d8f81f3110b0405f6", false},
{103, "long message",
"649e373e681ef52e3c10ac265484750932a9918f28fb824f7cb50adab39781fe",
"39b447bd3a01983c1cb761b456d69000948ceb870562a536126a0d18a8e7e49b16de8fe67"
"2f13d0808d8b7d957899917",
"151618eec4f503f3b63b539de0a58966", false},
{104, "long message",
"7b0d237f7b536e2c6950990e61b361b384333dda690045c591321a4e3f79747f",
"3d6283d11c0219b525620e9bf5b9fd887d3f0f707acb1fbdffab0d97a5c6d07fc547762e0"
"e7dd7c43ad35fab1c790f8047",
"ce201c0dcfdc3f2bef360609a31fb19e", false},
{105, "long message",
"17c92663741f012e5bb6714e614c2d155948617f10936269d954c58aba2ae62d",
"7fdd6a15c861d0313f6635d77dc55e115ff18c8ab063b5d03eab472eeca87a378188f2581"
"3515cf90b6cffa94a8ff36b29d65603eab3fbd2aa9500b261e184049893dc6ca2010becac"
"163053f211070bdda621b8bd8af77e450268603b52db34c90be836dfebddef42303f724e6"
"3bf0f",
"76e8dfd94db4af9d79d9718eec46cb2d", false},
{106, "long message",
"424c6b22606fcc094ae82fc5d3cbe484174c2211b3ec778091cac34a8e38a152",
"d96ff062e2490e8e0c54c5a8b89e85b25a66d93d7c2b93bdfef846b70d38672746a4b988d"
"08f15a5c527ca4f2c80e53f7c6ac0521bc57ebe38209180cbf934e0bbeb58cfb63d75da64"
"af41d09ce174af1896f42522910fced35ea000402e95fd3ac7aa6d5e0a6b533b0879bc466"
"019b3a5e6b16e4bd1ea6cdfc9ccc1d6f0f0",
"eda709c7009714c372d0d6a63dfde469", false},
{107, "long message",
"15d553c8da433d53cdc7f15087a70349caab57b379a4078928ce9b99302e31a6",
"d6c0c53b73f74fb426adfdc143d70db7f7a8f8ed32a2faef263cf9ab117537b6b9d1728bd"
"1000c1f28906c6ce6ad21862bfa4d689c1a8ebe3868b992098b7f981b2af5189a6adedff5"
"3a6c70c83693f5c8d6385a9a8a4dca017c5716ac4d5b9765c5ca2ab5f9867e02795198c0b"
"9527e07d08af52dbcb91ceb3d8b412a2b2402",
"8ca1402bf8fc23442ac2067be925b828", false},
{108, "long message",
"ffe559468a1031dfb3ced2e381e74b5821a36d9abf5f2e59895a7fdca0fa56a0",
"238899a84a3cf15202a1fbef4741e133fb24c009a0cd83854c6d1d7c9266d4c3eafe6d1df"
"c18f13845ccdad7fe277627b5fd5ff2555ce6dfde1ee078540a0a3590c6d9bf2fb63ba9af"
"be9380e797be7cd017645c5a3613eef38ef89e3b7461e6e700ff2b4deef5636c9d2198b14"
"3f797ca1820a3dcc5d462ebf4a8c4c09eb202a23592eb9524082c79adda8fcd56d256041a"
"26bf8f523962ba911ce5a5786570d65be3c4df722ed8830302065febdf944715298a1fbb7"
"d10b68d7da2bf889324314ce51e815c7fbf03aa0a8358aff3a86eb7a33f9a4923660db304"
"7e793bebb0c6918f4395d400381723fdae2832c36efc8e368a68f30f6351c3bc942cd560",
"a830b313f4936dea56a3aefd6a3ebe7d", false},
{109, "Flipped bit 0 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d28b42096d80f45f826b44a9d5607de7", true},
{110, "Flipped bit 0 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d9b99f2709a3ca74172cbe93824c1f29",
true},
{111, "Flipped bit 1 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d18b42096d80f45f826b44a9d5607de7", true},
{112, "Flipped bit 1 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "dab99f2709a3ca74172cbe93824c1f29",
true},
{113, "Flipped bit 7 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"538b42096d80f45f826b44a9d5607de7", true},
{114, "Flipped bit 7 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "58b99f2709a3ca74172cbe93824c1f29",
true},
{115, "Flipped bit 8 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38a42096d80f45f826b44a9d5607de7", true},
{116, "Flipped bit 8 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b89f2709a3ca74172cbe93824c1f29",
true},
{117, "Flipped bit 31 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42896d80f45f826b44a9d5607de7", true},
{118, "Flipped bit 31 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99fa709a3ca74172cbe93824c1f29",
true},
{119, "Flipped bit 32 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096c80f45f826b44a9d5607de7", true},
{120, "Flipped bit 32 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2708a3ca74172cbe93824c1f29",
true},
{121, "Flipped bit 33 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096f80f45f826b44a9d5607de7", true},
{122, "Flipped bit 33 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f270ba3ca74172cbe93824c1f29",
true},
{123, "Flipped bit 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f4df826b44a9d5607de7", true},
{124, "Flipped bit 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3caf4172cbe93824c1f29",
true},
{125, "Flipped bit 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f836b44a9d5607de7", true},
{126, "Flipped bit 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74162cbe93824c1f29",
true},
{127, "Flipped bit 71 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f026b44a9d5607de7", true},
{128, "Flipped bit 71 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74972cbe93824c1f29",
true},
{129, "Flipped bit 77 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f824b44a9d5607de7", true},
{130, "Flipped bit 77 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74170cbe93824c1f29",
true},
{131, "Flipped bit 80 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b45a9d5607de7", true},
{132, "Flipped bit 80 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbf93824c1f29",
true},
{133, "Flipped bit 96 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d4607de7", true},
{134, "Flipped bit 96 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbe93834c1f29",
true},
{135, "Flipped bit 97 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d7607de7", true},
{136, "Flipped bit 97 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbe93804c1f29",
true},
{137, "Flipped bit 103 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a955607de7", true},
{138, "Flipped bit 103 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbe93024c1f29",
true},
{139, "Flipped bit 120 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607de6", true},
{140, "Flipped bit 120 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbe93824c1f28",
true},
{141, "Flipped bit 121 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607de5", true},
{142, "Flipped bit 121 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbe93824c1f2b",
true},
{143, "Flipped bit 126 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607da7", true},
{144, "Flipped bit 126 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbe93824c1f69",
true},
{145, "Flipped bit 127 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f45f826b44a9d5607d67", true},
{146, "Flipped bit 127 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3ca74172cbe93824c1fa9",
true},
{147, "Flipped bits 0 and 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d28b42096d80f45f836b44a9d5607de7", true},
{148, "Flipped bits 0 and 64 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d9b99f2709a3ca74162cbe93824c1f29",
true},
{149, "Flipped bits 31 and 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42896d80f4df826b44a9d5607de7", true},
{150, "Flipped bits 31 and 63 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99fa709a3caf4172cbe93824c1f29",
true},
{151, "Flipped bits 63 and 127 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d38b42096d80f4df826b44a9d5607d67", true},
{152, "Flipped bits 63 and 127 in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d8b99f2709a3caf4172cbe93824c1fa9",
true},
{153, "all bits of tag flipped",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"2c74bdf6927f0ba07d94bb562a9f8218", true},
{154, "all bits of tag flipped",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "274660d8f65c358be8d3416c7db3e0d6",
true},
{155, "Tag changed to all zero",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"00000000000000000000000000000000", true},
{156, "Tag changed to all zero",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "00000000000000000000000000000000",
true},
{157, "tag changed to all 1",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"ffffffffffffffffffffffffffffffff", true},
{158, "tag changed to all 1",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "ffffffffffffffffffffffffffffffff",
true},
{159, "msbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"530bc289ed0074df02ebc42955e0fd67", true},
{160, "msbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "58391fa789234af497ac3e1302cc9fa9",
true},
{161, "lsbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "",
"d28a43086c81f55e836a45a8d4617ce6", true},
{162, "lsbs changed in tag",
"000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f",
"000102030405060708090a0b0c0d0e0f", "d9b89e2608a2cb75162dbf92834d1e28",
true},
{163, "short key", "a349ac0a9f9f74e48e099cc3dbf9a9c9", "",
"3a8437b877b75cc08a4d8d7559a8fc6869a58c713da63d1d4b350d59b597e30c", false},
{164, "short key", "ac686ba0f1a51b4ec4f0b30492b7f556",
"2fa43a14ae500507deb95ab5bd32b0fe",
"008532a53d0c0ab22027ae249023375374e2239b959609e8339b05a15742a675", false},
{165, "short key", "73ef9ef1a4225e51e3c1db3ace1fa24f",
"ffad380d9aabb0acede5c1bf112925cdfc3d379fc2376a4fe2644490d0430ac3",
"9c7cb9f7c207ec46d1e3c55764731c4ab5ddbae4e1401e52a895df0cff4787c9", false},
{166, "short key", "e34f15c7bd819930fe9d66e0c166e61c", "",
"1d765ab9e29892f7bfec2975ad4bc2dc", false},
{167, "short key", "e09eaa5a3f5e56d279d5e7a03373f6ea",
"ef4eab37181f98423e53e947e7050fd0", "cfc19ec07902ec8be489606d8f40d172",
false},
{168, "short key", "9bd3902ed0996c869b572272e76f3889",
"a7ba19d49ee1ea02f098aa8e30c740d893a4456ccc294040484ed8a00a55f93e",
"ac50adad9785a89c7282d8ab881dc615", false},
{169, "long key",
"8a0c46eb8a2959e39865330079763341e7439dab149694ee57e0d61ec73d947e1d5301cd9"
"74e18a5e0d1cf0d2c37e8aadd9fd589d57ef32e47024a99bc3f70c077",
"", "f5bfb940561fb4db73ebba49bf2e4893bb0cca618a71b7ecf6aca38231e167ea",
false},
{170, "long key",
"2877ebb81f80334fd00516337446c5cf5ad4a3a2e197269e5b0ad1889dfe2b4b0aaa676fa"
"c55b36ce3affc7f1092ab89c53273a837bd5bc94d1a9d9e5b02e9856f",
"ba448db88f154f775028fdecf9e6752d",
"1690ed4180642899e0deb9ec2270374e8b0a484217f5a682c524316eca219b64", false},
{171, "long key",
"21178e26bc28ffc27c06f762ba190a627075856d7ca6feab79ac63149b17126e34fd9e559"
"0e0e90aac801df09505d8af2dd0a2703b352c573ac9d2cb063927f2af",
"7d5f1d6b993452b1b53a4375760d10a20d46a0ab9ec3943fc4b07a2ce735e731",
"e542ac8ac8f364bae4b7da8b7a0777df350f001de4e8cfa2d9ef0b15019496ec", false},
{172, "long key",
"813e0c078c221375e80590ace6774eafd2d2c242350988d02efa550e05aecbe100c1b8bf1"
"54c932cf9e57177015c816c42bc7fbc71ceaa5328c7316b7f0f30330f",
"", "bb6ab66f51e53fa086c9c61a26ca27e0", false},
{173, "long key",
"5713343096b0aaf0562a6b92c1a15535924160475a4e4233589159728c562e3b2ad96f740"
"c6a4da2bc3f768ce98c9bd66bac28d1646ff592028c940d455f35eeb4",
"71712de2fac1fb855673bff72af64257", "c18165b8b97db1ca5e2486a32b39731e",
false},
{174, "long key",
"7208afbecf5f1f34828f98b719414e280716de64f5edd1ae1c774153cd2022337bb20fade"
"1b7856f1dbfd40e2b4307f1293ceff1692ee90d8c90b5fdf953ab01a5",
"43b53302b604d613e62db002044a4782d572ac8fbd3cd0ece91b43bc52e18e98",
"2fecfe45d79339c57dddba68ab34f5f1", false}};
#endif // hmac_sha256_vectors_h__

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -32,6 +32,7 @@ typedef struct AesCmacTestVectorStr {
std::string tag;
bool invalid;
} AesCmacTestVector;
typedef AesCmacTestVector HmacTestVector;
typedef struct AesGcmKatValueStr {
uint32_t id;
@ -66,6 +67,8 @@ typedef struct EcdsaTestVectorStr {
bool valid;
} EcdsaTestVector;
typedef EcdsaTestVector DsaTestVector;
typedef struct EcdhTestVectorStr {
uint32_t id;
std::vector<uint8_t> private_key;
@ -75,6 +78,16 @@ typedef struct EcdhTestVectorStr {
bool valid;
} EcdhTestVector;
typedef struct HkdfTestVectorStr {
uint32_t id;
std::string ikm;
std::string salt;
std::string info;
std::string okm;
uint32_t size;
bool valid;
} HkdfTestVector;
typedef struct RsaSignatureTestVectorStr {
SECOidTag hash_oid;
uint32_t id;

Просмотреть файл

@ -158,10 +158,31 @@ class ECDH():
return result
class DSA():
pub_keys = {}
def format_testcase(self, testcase, key, hash_oid, keySize, out_defs):
key_name = "kPubKey"
if key in self.pub_keys:
key_name = self.pub_keys[key]
else:
key_name += str(len(self.pub_keys))
self.pub_keys[key] = key_name
out_defs.append('static const std::vector<uint8_t> ' + key_name + string_to_hex_array(key) + ';\n\n')
result = '\n// Comment: {}'.format(testcase['comment'])
result += '\n// tcID: {}\n'.format(testcase['tcId'])
result += '{{{}, {},\n'.format(hash_oid, testcase['tcId'])
result += '{},\n'.format(string_to_hex_array(testcase['sig']))
result += '{},\n'.format(key_name)
result += '{},\n'.format(string_to_hex_array(testcase['msg']))
valid = testcase['result'] == 'valid' or (testcase['result'] == 'acceptable' and 'NoLeadingZero' in testcase['flags'])
result += '{}}},\n'.format(str(valid).lower())
return result
class ECDSA():
"""Class that provides the generator function for a single ECDSA test case."""
def format_testcase(self, testcase, key, hash_oid, keySize):
def format_testcase(self, testcase, key, hash_oid, keySize, out_defs):
result = '\n// Comment: {}'.format(testcase['comment'])
result += '\n// tcID: {}\n'.format(testcase['tcId'])
result += '{{{}, {},\n'.format(hash_oid, testcase['tcId'])
@ -175,6 +196,19 @@ class ECDSA():
return result
class HKDF():
"""Class that provides the generator function for a single HKDF test case."""
def format_testcase(self, vector):
"""Format an HKDF testcase object. Return a string in C-header format."""
result = '{{ {},\n'.format(vector['tcId'])
for key in ['ikm', 'salt', 'info', "okm"]:
result += ' \"{}\",\n'.format(vector[key])
result += ' {},\n'.format(vector['size'])
result += ' {}}},\n\n'.format(str(vector['result'] == 'valid').lower())
return result
class RSA_PKCS1_SIGNATURE():
pub_keys = {}
@ -327,7 +361,7 @@ def generate_vectors_file(params):
if 'key' in group:
if 'curve' in group['key'] and group['key']['curve'] not in ['secp256r1', 'secp384r1', 'secp521r1']:
continue
vectors_file += params['formatter'].format_testcase(test, group['keyDer'], getSha(group['sha']), group['key']['keySize'])
vectors_file += params['formatter'].format_testcase(test, group['keyDer'], getSha(group['sha']), group['key']['keySize'], shared_defs)
elif 'type' in group and group['type'] == 'RsassaPssVerify':
sLen = group['sLen'] if 'sLen' in group else 0
vectors_file += params['formatter'].format_testcase(test, group['keyDer'], getSha(group['sha']), getMgfSha(group['mgfSha']), sLen, shared_defs)
@ -448,6 +482,61 @@ curve25519_params = {
// tests at this moment because validity of the public key is not checked.\n'
}
dsa_params = {
'source_dir': 'source_vectors/',
'source_file': 'dsa_test.json',
'target': '../testvectors/dsa-vectors.h',
'array_init': 'const DsaTestVector kDsaWycheproofVectors[] = {\n',
'formatter' : DSA(),
'crop_size_end': -2,
'section': 'dsa_vectors_h__',
'comment' : ''
}
hkdf_sha1_params = {
'source_dir': 'source_vectors/',
'source_file': 'hkdf_sha1_test.json',
'target': '../testvectors/hkdf-sha1-vectors.h',
'array_init': 'const HkdfTestVector kHkdfSha1WycheproofVectors[] = {\n',
'formatter' : HKDF(),
'crop_size_end': -3,
'section': 'hkdf_sha1_vectors_h__',
'comment' : ''
}
hkdf_sha256_params = {
'source_dir': 'source_vectors/',
'source_file': 'hkdf_sha256_test.json',
'target': '../testvectors/hkdf-sha256-vectors.h',
'array_init': 'const HkdfTestVector kHkdfSha256WycheproofVectors[] = {\n',
'formatter' : HKDF(),
'crop_size_end': -3,
'section': 'hkdf_sha256_vectors_h__',
'comment' : ''
}
hkdf_sha384_params = {
'source_dir': 'source_vectors/',
'source_file': 'hkdf_sha384_test.json',
'target': '../testvectors/hkdf-sha384-vectors.h',
'array_init': 'const HkdfTestVector kHkdfSha384WycheproofVectors[] = {\n',
'formatter' : HKDF(),
'crop_size_end': -3,
'section': 'hkdf_sha384_vectors_h__',
'comment' : ''
}
hkdf_sha512_params = {
'source_dir': 'source_vectors/',
'source_file': 'hkdf_sha512_test.json',
'target': '../testvectors/hkdf-sha512-vectors.h',
'array_init': 'const HkdfTestVector kHkdfSha512WycheproofVectors[] = {\n',
'formatter' : HKDF(),
'crop_size_end': -3,
'section': 'hkdf_sha512_vectors_h__',
'comment' : ''
}
p256ecdh_params = {
'source_dir': 'source_vectors/',
'source_file': 'ecdh_secp256r1_test.json',
@ -830,6 +919,11 @@ def generate_test_vectors():
aes_gcm_params,
chacha_poly_params,
curve25519_params,
dsa_params,
hkdf_sha1_params,
hkdf_sha256_params,
hkdf_sha384_params,
hkdf_sha512_params,
p256ecdsa_sha256_params,
p384ecdsa_sha384_params,
p521ecdsa_sha512_params,

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -16,13 +16,15 @@ CPPSRCS = \
pk11_curve25519_unittest.cc \
pk11_der_private_key_import_unittest.cc \
pk11_des_unittest.cc \
pk11_dsa_unittest.cc \
pk11_ecdsa_unittest.cc \
pk11_ecdh_unittest.cc \
pk11_encrypt_derive_unittest.cc \
pk11_export_unittest.cc \
pk11_find_certs_unittest.cc \
pk11_hpke_unittest.cc \
pk11_hkdf_unittest.cc \
pk11_hmac_unittest.cc \
pk11_hpke_unittest.cc \
pk11_import_unittest.cc \
pk11_kbkdf.cc \
pk11_keygen.cc \

Просмотреть файл

@ -0,0 +1,79 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=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/. */
#include <memory>
#include "nss.h"
#include "pk11pub.h"
#include "sechash.h"
#include "cryptohi.h"
#include "cpputil.h"
#include "databuffer.h"
#include "gtest/gtest.h"
#include "nss_scoped_ptrs.h"
#include "testvectors/dsa-vectors.h"
namespace nss_test {
class Pkcs11DsaTest : public ::testing::TestWithParam<DsaTestVector> {
protected:
void Derive(const uint8_t* sig, size_t sig_len, const uint8_t* spki,
size_t spki_len, const uint8_t* data, size_t data_len,
bool expect_success, const uint32_t test_id,
const SECOidTag hash_oid) {
std::stringstream s;
s << "Test with original ID #" << test_id << " failed.\n";
s << "Expected Success: " << expect_success << "\n";
std::string msg = s.str();
SECItem spki_item = {siBuffer, toUcharPtr(spki),
static_cast<unsigned int>(spki_len)};
ScopedCERTSubjectPublicKeyInfo cert_spki(
SECKEY_DecodeDERSubjectPublicKeyInfo(&spki_item));
ASSERT_TRUE(cert_spki) << msg;
ScopedSECKEYPublicKey pub_key(SECKEY_ExtractPublicKey(cert_spki.get()));
ASSERT_TRUE(pub_key) << msg;
SECItem sig_item = {siBuffer, toUcharPtr(sig),
static_cast<unsigned int>(sig_len)};
ScopedSECItem decoded_sig_item(
DSAU_DecodeDerSigToLen(&sig_item, SECKEY_SignatureLen(pub_key.get())));
if (!decoded_sig_item) {
ASSERT_FALSE(expect_success) << msg;
return;
}
DataBuffer hash;
hash.Allocate(static_cast<size_t>(HASH_ResultLenByOidTag(hash_oid)));
SECStatus rv = PK11_HashBuf(hash_oid, toUcharPtr(hash.data()),
toUcharPtr(data), data_len);
ASSERT_EQ(SECSuccess, rv) << msg;
// Verify.
SECItem hash_item = {siBuffer, toUcharPtr(hash.data()),
static_cast<unsigned int>(hash.len())};
rv = PK11_VerifyWithMechanism(pub_key.get(), CKM_DSA, nullptr,
decoded_sig_item.get(), &hash_item, nullptr);
EXPECT_EQ(expect_success ? SECSuccess : SECFailure, rv);
};
void Derive(const DsaTestVector vector) {
Derive(vector.sig.data(), vector.sig.size(), vector.public_key.data(),
vector.public_key.size(), vector.msg.data(), vector.msg.size(),
vector.valid, vector.id, vector.hash_oid);
};
};
TEST_P(Pkcs11DsaTest, WycheproofVectors) { Derive(GetParam()); }
INSTANTIATE_TEST_CASE_P(DsaTest, Pkcs11DsaTest,
::testing::ValuesIn(kDsaWycheproofVectors));
} // namespace nss_test

Просмотреть файл

@ -22,11 +22,13 @@
'pk11_curve25519_unittest.cc',
'pk11_der_private_key_import_unittest.cc',
'pk11_des_unittest.cc',
'pk11_dsa_unittest.cc',
'pk11_ecdsa_unittest.cc',
'pk11_ecdh_unittest.cc',
'pk11_encrypt_derive_unittest.cc',
'pk11_find_certs_unittest.cc',
'pk11_hkdf_unittest.cc',
'pk11_hmac_unittest.cc',
'pk11_hpke_unittest.cc',
'pk11_import_unittest.cc',
'pk11_kbkdf.cc',

Просмотреть файл

@ -12,238 +12,188 @@
#include "pk11pub.h"
#include "secerr.h"
#include "sechash.h"
#include "testvectors/hkdf-vectors.h"
#include "util.h"
#include "testvectors/hkdf-sha1-vectors.h"
#include "testvectors/hkdf-sha256-vectors.h"
#include "testvectors/hkdf-sha384-vectors.h"
#include "testvectors/hkdf-sha512-vectors.h"
namespace nss_test {
/* different mechanisms for the tests */
typedef int HkdfTestType;
const int kNSSHkdfLegacy = 0;
const int kPkcs11HkdfDerive = 1;
const int kPkcs11HkdfDeriveDataKey = 2;
const int kPkcs11HkdfSaltDerive = 3;
const int kPkcs11HkdfData = 4;
const int kPKCS11NumTypes = 5;
enum class Pk11ImportType { data = 0, key = 1 };
static const Pk11ImportType kImportTypesAll[] = {Pk11ImportType::data,
Pk11ImportType::key};
enum class HkdfTestType {
legacy, /* CKM_NSS_HKDF_SHA... */
derive, /* CKM_HKDF_DERIVE, ikm as secret key, salt as data. */
deriveDataKey, /* CKM_HKDF_DERIVE, ikm as data, salt as data. */
saltDerive, /* CKM_HKDF_DERIVE, [ikm, salt] as secret key, salt as key. */
saltDeriveDataKey, /* CKM_HKDF_DERIVE, [ikm, salt] as data, salt as key. */
hkdfData /* CKM_HKDF_DATA, ikm as data, salt as data. */
};
static const HkdfTestType kHkdfTestTypesAll[] = {
HkdfTestType::legacy,
HkdfTestType::derive,
HkdfTestType::deriveDataKey,
HkdfTestType::saltDerive,
HkdfTestType::saltDeriveDataKey,
HkdfTestType::hkdfData,
};
class Pkcs11HkdfTest
: public ::testing::TestWithParam<std::tuple<hkdf_vector, Pk11ImportType>> {
: public ::testing::TestWithParam<
std::tuple<HkdfTestVector, HkdfTestType, CK_MECHANISM_TYPE>> {
protected:
CK_MECHANISM_TYPE Pk11HkdfToHash(CK_MECHANISM_TYPE nssHkdfMech) {
switch (nssHkdfMech) {
case CKM_NSS_HKDF_SHA1:
return CKM_SHA_1;
case CKM_NSS_HKDF_SHA256:
return CKM_SHA256;
case CKM_NSS_HKDF_SHA384:
return CKM_SHA384;
case CKM_NSS_HKDF_SHA512:
return CKM_SHA512;
CK_MECHANISM_TYPE Pk11MechToVendorMech(CK_MECHANISM_TYPE pk11_mech) {
switch (pk11_mech) {
case CKM_SHA_1:
return CKM_NSS_HKDF_SHA1;
case CKM_SHA256:
return CKM_NSS_HKDF_SHA256;
case CKM_SHA384:
return CKM_NSS_HKDF_SHA384;
case CKM_SHA512:
return CKM_NSS_HKDF_SHA512;
default:
break;
}
ADD_FAILURE() << "Unknown hash mech";
return CKM_INVALID_MECHANISM;
}
}
ScopedPK11SymKey ImportKey(CK_KEY_TYPE key_type, SECItem *ikm_item,
Pk11ImportType import_type) {
ScopedPK11SymKey ImportKey(SECItem &ikm_item, bool import_as_data) {
ScopedPK11SlotInfo slot(PK11_GetInternalSlot());
CK_MECHANISM_TYPE mech = CKM_HKDF_KEY_GEN;
if (!slot) {
ADD_FAILURE() << "Can't get slot";
return nullptr;
}
switch (key_type) {
case CKK_GENERIC_SECRET:
mech = CKM_GENERIC_SECRET_KEY_GEN;
break;
case CKK_HKDF:
mech = CKM_HKDF_KEY_GEN;
break;
}
ScopedPK11SymKey ikm;
if (import_type == Pk11ImportType::key) {
ikm.reset(PK11_ImportSymKey(slot.get(), mech, PK11_OriginUnwrap, CKA_SIGN,
ikm_item, nullptr));
if (import_as_data) {
ikm.reset(PK11_ImportDataKey(slot.get(), CKM_HKDF_KEY_GEN,
PK11_OriginUnwrap, CKA_SIGN, &ikm_item,
nullptr));
} else {
ikm.reset(PK11_ImportDataKey(slot.get(), mech, PK11_OriginUnwrap,
CKA_SIGN, ikm_item, nullptr));
ikm.reset(PK11_ImportSymKey(slot.get(), CKM_GENERIC_SECRET_KEY_GEN,
PK11_OriginUnwrap, CKA_SIGN, &ikm_item,
nullptr));
}
return ikm;
}
void RunTest(hkdf_vector vec, HkdfTestType test_type, CK_KEY_TYPE key_type,
Pk11ImportType import_type) {
SECItem ikm_item = {siBuffer, vec.ikm.data(),
static_cast<unsigned int>(vec.ikm.size())};
SECItem salt_item = {siBuffer, vec.salt.data(),
static_cast<unsigned int>(vec.salt.size())};
CK_MECHANISM_TYPE derive_mech = vec.mech;
CK_NSS_HKDFParams nss_hkdf_params = {
true, vec.salt.data(), static_cast<unsigned int>(vec.salt.size()),
true, vec.info.data(), static_cast<unsigned int>(vec.info.size())};
CK_HKDF_PARAMS hkdf_params = {true,
true,
vec.mech,
CKF_HKDF_SALT_DATA,
vec.salt.data(),
static_cast<unsigned int>(vec.salt.size()),
CK_INVALID_HANDLE,
vec.info.data(),
static_cast<unsigned int>(vec.info.size())};
SECItem params_item = {siBuffer, (unsigned char *)&nss_hkdf_params,
sizeof(nss_hkdf_params)};
void RunWycheproofTest(const HkdfTestVector &vec, HkdfTestType test_type,
CK_MECHANISM_TYPE hash_mech) {
std::string msg = "Test #" + std::to_string(vec.id) + " failed";
std::vector<uint8_t> vec_ikm = hex_string_to_bytes(vec.ikm);
std::vector<uint8_t> vec_okm = hex_string_to_bytes(vec.okm);
std::vector<uint8_t> vec_info = hex_string_to_bytes(vec.info);
std::vector<uint8_t> vec_salt = hex_string_to_bytes(vec.salt);
SECItem ikm_item = {siBuffer, vec_ikm.data(),
static_cast<unsigned int>(vec_ikm.size())};
SECItem okm_item = {siBuffer, vec_okm.data(),
static_cast<unsigned int>(vec_okm.size())};
SECItem salt_item = {siBuffer, vec_salt.data(),
static_cast<unsigned int>(vec_salt.size())};
CK_MECHANISM_TYPE derive_mech = CKM_HKDF_DERIVE;
ScopedPK11SymKey salt_key = nullptr;
ScopedPK11SymKey ikm = nullptr;
ScopedPK11SymKey ikm = ImportKey(key_type, &ikm_item, import_type);
ScopedPK11SymKey salt_key = NULL;
ASSERT_NE(nullptr, ikm.get());
// Legacy vendor mech params
CK_NSS_HKDFParams nss_hkdf_params = {
true, vec_salt.data(), static_cast<unsigned int>(vec_salt.size()),
true, vec_info.data(), static_cast<unsigned int>(vec_info.size())};
// PKCS #11 v3.0
CK_HKDF_PARAMS hkdf_params = {
true,
true,
hash_mech,
vec_salt.size() ? CKF_HKDF_SALT_DATA : CKF_HKDF_SALT_NULL,
vec_salt.size() ? vec_salt.data() : nullptr,
static_cast<unsigned int>(vec_salt.size()),
CK_INVALID_HANDLE,
vec_info.data(),
static_cast<unsigned int>(vec_info.size())};
SECItem params_item = {siBuffer, (unsigned char *)&hkdf_params,
sizeof(hkdf_params)};
switch (test_type) {
case kNSSHkdfLegacy:
printf("kNSSHkdfLegacy\n");
break; /* already set up */
case kPkcs11HkdfDeriveDataKey: {
ScopedPK11SlotInfo slot(PK11_GetSlotFromKey(ikm.get()));
/* replaces old key with our new data key */
SECItem data_item = {siBuffer, vec.ikm.data(),
static_cast<unsigned int>(vec.ikm.size())};
ikm = ScopedPK11SymKey(PK11_ImportDataKey(slot.get(), CKM_HKDF_DERIVE,
PK11_OriginUnwrap, CKA_DERIVE,
&data_item, NULL));
ASSERT_NE(nullptr, ikm.get());
case HkdfTestType::legacy:
derive_mech = Pk11MechToVendorMech(hash_mech);
params_item.data = (uint8_t *)&nss_hkdf_params;
params_item.len = sizeof(nss_hkdf_params);
ikm = ImportKey(ikm_item, false);
break;
case HkdfTestType::derive:
ikm = ImportKey(ikm_item, false);
break;
case HkdfTestType::deriveDataKey:
ikm = ImportKey(ikm_item, true);
break;
case HkdfTestType::saltDerive:
ikm = ImportKey(ikm_item, false);
salt_key = ImportKey(salt_item, false);
break;
case HkdfTestType::saltDeriveDataKey:
ikm = ImportKey(ikm_item, true);
salt_key = ImportKey(salt_item, true);
break;
case HkdfTestType::hkdfData:
derive_mech = CKM_HKDF_DATA;
ikm = ImportKey(ikm_item, true);
break;
default:
ADD_FAILURE() << msg;
return;
}
/* fall through */
case kPkcs11HkdfSaltDerive:
case kPkcs11HkdfDerive:
if (hkdf_params.ulSaltLen == 0) {
hkdf_params.ulSaltType = CKF_HKDF_SALT_NULL;
printf("kPkcs11HkdfNullSaltDerive\n");
} else if (test_type == kPkcs11HkdfSaltDerive) {
salt_key = ImportKey(key_type, &salt_item, import_type);
ASSERT_NE(nullptr, ikm) << msg;
if (test_type == HkdfTestType::saltDerive ||
test_type == HkdfTestType::saltDeriveDataKey) {
ASSERT_NE(nullptr, salt_key) << msg;
hkdf_params.ulSaltType = CKF_HKDF_SALT_KEY;
hkdf_params.ulSaltLen = 0;
hkdf_params.pSalt = NULL;
hkdf_params.hSaltKey = PK11_GetSymKeyHandle(salt_key.get());
printf("kPkcs11HkdfSaltDerive\n");
} else {
printf("kPkcs11HkdfDerive%s\n",
(test_type == kPkcs11HkdfDeriveDataKey) ? "DataKey" : "");
}
hkdf_params.prfHashMechanism = Pk11HkdfToHash(vec.mech);
params_item.data = (unsigned char *)&hkdf_params;
params_item.len = sizeof(hkdf_params);
derive_mech = CKM_HKDF_DERIVE;
break;
case kPkcs11HkdfData:
printf("kPkcs11HkdfData\n");
if (hkdf_params.ulSaltLen == 0) {
hkdf_params.ulSaltType = CKF_HKDF_SALT_NULL;
}
hkdf_params.prfHashMechanism = Pk11HkdfToHash(vec.mech);
params_item.data = (unsigned char *)&hkdf_params;
params_item.len = sizeof(hkdf_params);
derive_mech = CKM_HKDF_DATA;
break;
}
ASSERT_NE(derive_mech, CKM_INVALID_MECHANISM);
ScopedPK11SymKey okm = ScopedPK11SymKey(
PK11_Derive(ikm.get(), derive_mech, &params_item,
CKM_GENERIC_SECRET_KEY_GEN, CKA_DERIVE, vec.l));
if (vec.res.expect_rv == SECSuccess) {
ASSERT_NE(nullptr, okm.get());
if (vec.res.output_match) {
ASSERT_EQ(SECSuccess, PK11_ExtractKeyValue(okm.get()));
SECItem *act_okm_item = PK11_GetKeyData(okm.get());
SECItem vec_okm_item = {siBuffer, vec.okm.data(),
static_cast<unsigned int>(vec.okm.size())};
ASSERT_EQ(0, SECITEM_CompareItem(&vec_okm_item, act_okm_item));
}
CKM_GENERIC_SECRET_KEY_GEN, CKA_DERIVE, vec.size));
if (vec.valid) {
ASSERT_NE(nullptr, okm.get()) << msg;
ASSERT_EQ(SECSuccess, PK11_ExtractKeyValue(okm.get())) << msg;
ASSERT_EQ(0, SECITEM_CompareItem(&okm_item, PK11_GetKeyData(okm.get())))
<< msg;
} else {
ASSERT_EQ(nullptr, okm.get());
}
}
void RunTest(hkdf_vector vec, Pk11ImportType import_type) {
HkdfTestType test_type;
for (test_type = kNSSHkdfLegacy; test_type < kPKCS11NumTypes; test_type++) {
RunTest(vec, test_type, CKK_GENERIC_SECRET, import_type);
if (test_type == kPkcs11HkdfDeriveDataKey) {
continue;
}
RunTest(vec, test_type, CKK_HKDF, import_type);
ASSERT_EQ(nullptr, okm.get()) << msg;
}
}
};
TEST_P(Pkcs11HkdfTest, TestVectors) {
RunTest(std::get<0>(GetParam()), std::get<1>(GetParam()));
TEST_P(Pkcs11HkdfTest, WycheproofVectors) {
RunWycheproofTest(std::get<0>(GetParam()), std::get<1>(GetParam()),
std::get<2>(GetParam()));
}
INSTANTIATE_TEST_CASE_P(
Pkcs11HkdfTests, Pkcs11HkdfTest,
::testing::Combine(::testing::ValuesIn(kHkdfTestVectors),
::testing::ValuesIn(kImportTypesAll)));
HkdfSha1, Pkcs11HkdfTest,
::testing::Combine(::testing::ValuesIn(kHkdfSha1WycheproofVectors),
::testing::ValuesIn(kHkdfTestTypesAll),
::testing::Values(CKM_SHA_1)));
TEST_F(Pkcs11HkdfTest, OkmLimits) {
hkdf_vector vector{
0,
CKM_NSS_HKDF_SHA1,
255 * SHA1_LENGTH /* per rfc5869 */,
{0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b},
{},
{},
{},
{SECSuccess, false} /* Only looking at return value */
};
INSTANTIATE_TEST_CASE_P(
HkdfSha256, Pkcs11HkdfTest,
::testing::Combine(::testing::ValuesIn(kHkdfSha256WycheproofVectors),
::testing::ValuesIn(kHkdfTestTypesAll),
::testing::Values(CKM_SHA256)));
// SHA1 limit
RunTest(vector, Pk11ImportType::key);
INSTANTIATE_TEST_CASE_P(
HkdfSha384, Pkcs11HkdfTest,
::testing::Combine(::testing::ValuesIn(kHkdfSha384WycheproofVectors),
::testing::ValuesIn(kHkdfTestTypesAll),
::testing::Values(CKM_SHA384)));
// SHA1 limit + 1
vector.l += 1;
vector.res.expect_rv = SECFailure;
RunTest(vector, Pk11ImportType::key);
// SHA256 limit
vector.mech = CKM_NSS_HKDF_SHA256;
vector.l = 255 * SHA256_LENGTH; /* per rfc5869 */
vector.res.expect_rv = SECSuccess;
RunTest(vector, Pk11ImportType::data);
// SHA256 limit + 1
vector.l += 1;
vector.res.expect_rv = SECFailure;
RunTest(vector, Pk11ImportType::data);
// SHA384 limit
vector.mech = CKM_NSS_HKDF_SHA384;
vector.l = 255 * SHA384_LENGTH; /* per rfc5869 */
vector.res.expect_rv = SECSuccess;
RunTest(vector, Pk11ImportType::key);
// SHA384 limit + 1
vector.l += 1;
vector.res.expect_rv = SECFailure;
RunTest(vector, Pk11ImportType::key);
// SHA512 limit
vector.mech = CKM_NSS_HKDF_SHA512;
vector.l = 255 * SHA512_LENGTH; /* per rfc5869 */
vector.res.expect_rv = SECSuccess;
RunTest(vector, Pk11ImportType::data);
// SHA512 limit + 1
vector.l += 1;
vector.res.expect_rv = SECFailure;
RunTest(vector, Pk11ImportType::data);
}
INSTANTIATE_TEST_CASE_P(
HkdfSha512, Pkcs11HkdfTest,
::testing::Combine(::testing::ValuesIn(kHkdfSha512WycheproofVectors),
::testing::ValuesIn(kHkdfTestTypesAll),
::testing::Values(CKM_SHA512)));
} // namespace nss_test

Просмотреть файл

@ -0,0 +1,74 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=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/. */
#include <memory>
#include <tuple>
#include "nss.h"
#include "pk11pub.h"
#include "secerr.h"
#include "sechash.h"
#include "blapi.h"
#include "gtest/gtest.h"
#include "nss_scoped_ptrs.h"
#include "testvectors/hmac-sha256-vectors.h"
#include "testvectors/hmac-sha384-vectors.h"
#include "testvectors/hmac-sha512-vectors.h"
#include "util.h"
namespace nss_test {
class Pkcs11HmacTest : public ::testing::TestWithParam<
std::tuple<HmacTestVector, CK_MECHANISM_TYPE>> {
protected:
void RunTestVector(const HmacTestVector &vec, CK_MECHANISM_TYPE mech) {
std::string err = "Test #" + std::to_string(vec.id) + " failed";
std::vector<uint8_t> vec_key = hex_string_to_bytes(vec.key);
std::vector<uint8_t> vec_mac = hex_string_to_bytes(vec.tag);
std::vector<uint8_t> vec_msg = hex_string_to_bytes(vec.msg);
std::vector<uint8_t> output(vec_mac.size());
// Don't provide a null pointer, even if the input is empty.
uint8_t tmp;
SECItem key = {siBuffer, vec_key.data() ? vec_key.data() : &tmp,
static_cast<unsigned int>(vec_key.size())};
SECItem mac = {siBuffer, vec_mac.data() ? vec_mac.data() : &tmp,
static_cast<unsigned int>(vec_mac.size())};
SECItem msg = {siBuffer, vec_msg.data() ? vec_msg.data() : &tmp,
static_cast<unsigned int>(vec_msg.size())};
SECItem out = {siBuffer, output.data() ? output.data() : &tmp,
static_cast<unsigned int>(output.size())};
ScopedPK11SlotInfo slot(PK11_GetInternalSlot());
ASSERT_NE(nullptr, slot) << err;
ScopedPK11SymKey p11_key(PK11_ImportSymKey(
slot.get(), mech, PK11_OriginUnwrap, CKA_SIGN, &key, nullptr));
ASSERT_NE(nullptr, p11_key.get()) << err;
SECStatus rv = PK11_SignWithSymKey(p11_key.get(), mech, NULL, &out, &msg);
EXPECT_EQ(SECSuccess, rv) << err;
EXPECT_EQ(!vec.invalid, 0 == SECITEM_CompareItem(&out, &mac)) << err;
}
};
TEST_P(Pkcs11HmacTest, WycheproofVectors) {
RunTestVector(std::get<0>(GetParam()), std::get<1>(GetParam()));
}
INSTANTIATE_TEST_CASE_P(
HmacSha256, Pkcs11HmacTest,
::testing::Combine(::testing::ValuesIn(kHmacSha256WycheproofVectors),
::testing::Values(CKM_SHA256_HMAC)));
INSTANTIATE_TEST_CASE_P(
HmacSha384, Pkcs11HmacTest,
::testing::Combine(::testing::ValuesIn(kHmacSha384WycheproofVectors),
::testing::Values(CKM_SHA384_HMAC)));
INSTANTIATE_TEST_CASE_P(
HmacSha512, Pkcs11HmacTest,
::testing::Combine(::testing::ValuesIn(kHmacSha512WycheproofVectors),
::testing::Values(CKM_SHA512_HMAC)));
} // namespace nss_test

Просмотреть файл

@ -171,11 +171,12 @@ nssSlot_IsTokenPresent(
nssSlot_EnterMonitor(slot);
ckrv = CKAPI(epv)->C_GetSlotInfo(slot->slotID, &slotInfo);
nssSlot_ExitMonitor(slot);
if (ckrv != CKR_OK) {
if (slot->token) {
slot->token->base.name[0] = 0; /* XXX */
}
isPresent = PR_FALSE;
goto done;
goto done; /* slot lock held */
}
slot->ckFlags = slotInfo.flags;
/* check for the presence of the token */
@ -183,7 +184,7 @@ nssSlot_IsTokenPresent(
if (!slot->token) {
/* token was never present */
isPresent = PR_FALSE;
goto done;
goto done; /* slot lock held */
}
session = nssToken_GetDefaultSession(slot->token);
if (session) {
@ -206,8 +207,16 @@ nssSlot_IsTokenPresent(
/* clear the token cache */
nssToken_Remove(slot->token);
isPresent = PR_FALSE;
goto done;
goto done; /* slot lock held */
}
if (!slot->token) {
/* This should not occur, based on the fact that the
* below calls will dereference NULL otherwise. */
PORT_Assert(0);
isPresent = PR_FALSE;
goto done; /* slot lock held */
}
/* token is present, use the session info to determine if the card
* has been removed and reinserted.
*/
@ -230,7 +239,7 @@ nssSlot_IsTokenPresent(
/* token not removed, finished */
if (!tokenRemoved) {
isPresent = PR_TRUE;
goto done;
goto done; /* slot lock held */
}
}
/* the token has been removed, and reinserted, or the slot contains
@ -248,6 +257,7 @@ nssSlot_IsTokenPresent(
isPresent = PR_FALSE;
}
done:
nssSlot_ExitMonitor(slot);
/* Once we've set up the condition variable,
* Before returning, it's necessary to:
* 1) Set the lastTokenPingTime so that any other threads waiting on this

Просмотреть файл

@ -96,6 +96,9 @@ struct NSSSlotStr {
};
struct nssSessionStr {
/* Must not hold slot->lock when taking lock.
* See ordering in nssSlot_IsTokenPresent.
*/
PZLock *lock;
CK_SESSION_HANDLE handle;
NSSSlot *slot;

Просмотреть файл

@ -861,7 +861,10 @@ secmod_parseCryptoPolicy(const char *policyConfig, PRBool printPolicyFeedback)
/* don't overwrite other (future) lock flags */
rv = NSS_OptionGet(NSS_DEFAULT_LOCKS, &locks);
if (rv == SECSuccess) {
NSS_OptionSet(NSS_DEFAULT_LOCKS, locks | NSS_DEFAULT_SSL_LOCK);
rv = NSS_OptionSet(NSS_DEFAULT_LOCKS, locks | NSS_DEFAULT_SSL_LOCK);
}
if (rv != SECSuccess) {
return rv;
}
}
if (NSSUTIL_ArgHasFlag("flags", "policy-lock", policyConfig)) {

Просмотреть файл

@ -5793,7 +5793,7 @@ urlbar.searchmode:
- 1665076
description: >
A keyed uint recording how many times the user entered a particular search
mode after selecing the Search Bookmarks menu item in the Library menu.
mode after being handed off from the search bar on the new tab page.
expires: never
kind: uint
keyed: true
@ -5861,7 +5861,7 @@ urlbar.searchmode:
- 1665076
description: >
A keyed uint recording how many times the user entered a particular search
mode after selecing the Search Tabs menu item in the Tab Overflow menu.
mode after selecting the Search Tabs menu item in the Tab Overflow menu.
expires: never
kind: uint
keyed: true
@ -5929,7 +5929,7 @@ urlbar.searchmode:
- 1654680
description: >
A keyed uint recording how many times the user entered a particular search
mode after selecting a search shortcut Top Site in the Urlbar..
mode after selecting a search shortcut Top Site in the Urlbar.
expires: never
kind: uint
keyed: true
@ -5994,6 +5994,242 @@ urlbar.searchmode:
record_in_processes:
- main
urlbar.picked.searchmode:
bookmarkmenu:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode from the Search
Bookmarks menu item in the Library menu.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
handoff:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by being handed off
from the search bar on the new tab page.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
keywordoffer:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting a
keyword offer result.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
oneoff:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting a
one-off.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
shortcut:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by pressing a
keyboard shortcut.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
tabmenu:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting the
Search Tabs menu item in the Tab Overflow menu.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
tabtosearch:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting a
tab-to-search result.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
tabtosearch_onboard:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting a
tab-to-search onboarding result.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
topsites_newtab:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting a
search shortcut Top Site on the New Tab Page.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
topsites_urlbar:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting a
search shortcut Top Site in the Urlbar.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
touchbar:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by selecting a
search shortcut on the macOS Touch Bar.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
typed:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode by typing an alias.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
other:
bug_numbers:
- 1674874
description: >
A keyed uint recording how many times the user picked a particular kind of
result while in search mode after entering search mode from an unknown
entry point. If values appear for this probe in Telemetry, we should
review the entry points to search mode.
expires: never
kind: uint
keyed: true
notification_emails:
- fx-search@mozilla.com
- tbrooks@mozilla.com
release_channel_collection: opt-out
products:
- 'firefox'
record_in_processes:
- main
migration:
uninstaller_profile_refresh:

Просмотреть файл

@ -402,6 +402,7 @@ module.exports = {
PannerNode: false,
ParentProcessMessageManager: false,
Path2D: false,
PathUtils: false,
PaymentAddress: false,
PaymentMethodChangeEvent: false,
PaymentRequest: false,