mirror of
https://github.com/dart-lang/sdk
synced 2024-10-07 09:55:05 +00:00
pkg/analyzer: support latest pkg/crypto version
BUG= https://github.com/dart-lang/sdk/issues/26138 R=brianwilkerson@google.com, paulberry@google.com Review URL: https://codereview.chromium.org/1890973003 .
This commit is contained in:
parent
fcf5278b6c
commit
5b5312a67c
4
DEPS
4
DEPS
|
@ -40,7 +40,7 @@ vars = {
|
|||
"cli_util_tag" : "@0.0.1+2",
|
||||
"collection_rev": "@f6135e6350c63eb3f4dd12953b8d4363faff16fc",
|
||||
"convert_tag": "@1.0.0",
|
||||
"crypto_rev" : "@2df57a1e26dd88e8d0614207d4b062c73209917d",
|
||||
"crypto_tag" : "@1.1.0",
|
||||
"csslib_tag" : "@0.12.0",
|
||||
"dart2js_info_rev" : "@0a221eaf16aec3879c45719de656680ccb80d8a1",
|
||||
"dartdoc_tag" : "@v0.9.0",
|
||||
|
@ -165,7 +165,7 @@ deps = {
|
|||
Var("dart_root") + "/third_party/pkg/convert":
|
||||
"https://github.com/dart-lang/convert.git" + Var("convert_tag"),
|
||||
Var("dart_root") + "/third_party/pkg/crypto":
|
||||
(Var("github_mirror") % "crypto") + Var("crypto_rev"),
|
||||
(Var("github_mirror") % "crypto") + Var("crypto_tag"),
|
||||
Var("dart_root") + "/third_party/pkg/csslib":
|
||||
(Var("github_mirror") % "csslib") + Var("csslib_tag"),
|
||||
Var("dart_root") + "/third_party/dart-services":
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:convert' show UTF8;
|
||||
import 'dart:convert' show ChunkedConversionSink, UTF8;
|
||||
import 'dart:core' hide Resource;
|
||||
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
|
@ -12,6 +12,7 @@ import 'package:analyzer/src/generated/source.dart';
|
|||
import 'package:analyzer/src/summary/format.dart';
|
||||
import 'package:analyzer/src/summary/idl.dart';
|
||||
import 'package:analyzer/src/summary/summarize_elements.dart';
|
||||
import 'package:convert/convert.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
|
||||
/**
|
||||
|
@ -242,7 +243,7 @@ class IncrementalCache {
|
|||
*/
|
||||
String _getCacheSourceContentKey(Source source) {
|
||||
List<int> hash = _getSourceContentHash(source);
|
||||
String hashStr = CryptoUtils.bytesToHex(hash);
|
||||
String hashStr = hex.encode(hash);
|
||||
return '$hashStr.content';
|
||||
}
|
||||
|
||||
|
@ -267,7 +268,7 @@ class IncrementalCache {
|
|||
*/
|
||||
String _getLibraryBundleKey(Source librarySource) {
|
||||
List<int> hash = _getLibraryClosureHash(librarySource);
|
||||
String hashStr = CryptoUtils.bytesToHex(hash);
|
||||
String hashStr = hex.encode(hash);
|
||||
return '$hashStr.summary';
|
||||
}
|
||||
|
||||
|
@ -291,13 +292,31 @@ class IncrementalCache {
|
|||
List<int> _getLibraryClosureHash(Source librarySource) {
|
||||
return _libraryClosureHashMap.putIfAbsent(librarySource, () {
|
||||
List<Source> closure = _getLibraryClosure(librarySource);
|
||||
MD5 md5 = new MD5();
|
||||
|
||||
Digest digest;
|
||||
|
||||
var digestSink = new ChunkedConversionSink<Digest>.withCallback(
|
||||
(List<Digest> digests) {
|
||||
digest = digests.single;
|
||||
});
|
||||
|
||||
var byteSink = md5.startChunkedConversion(digestSink);
|
||||
|
||||
for (Source source in closure) {
|
||||
List<int> sourceHash = _getSourceContentHash(source);
|
||||
md5.add(sourceHash);
|
||||
byteSink.add(sourceHash);
|
||||
}
|
||||
md5.add(configSalt);
|
||||
return md5.close();
|
||||
byteSink.add(configSalt);
|
||||
|
||||
byteSink.close();
|
||||
// TODO(paulberry): this call to `close` should not be needed.
|
||||
// Can be removed once
|
||||
// https://github.com/dart-lang/crypto/issues/33
|
||||
// is fixed – ensure the min version constraint on crypto is updated, tho.
|
||||
// Does not cause any problems in the mean time.
|
||||
digestSink.close();
|
||||
|
||||
return digest.bytes;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -308,7 +327,7 @@ class IncrementalCache {
|
|||
return _sourceContentHashMap.putIfAbsent(source, () {
|
||||
String sourceText = source.contents.data;
|
||||
List<int> sourceBytes = UTF8.encode(sourceText);
|
||||
return (new MD5()..add(sourceBytes)).close();
|
||||
return md5.convert(sourceBytes).bytes;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ import 'package:analyzer/src/summary/format.dart';
|
|||
import 'package:analyzer/src/summary/idl.dart';
|
||||
import 'package:analyzer/src/summary/name_filter.dart';
|
||||
import 'package:analyzer/src/summary/summarize_const_expr.dart';
|
||||
import 'package:convert/convert.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
|
@ -212,9 +213,7 @@ class PackageBundleAssembler {
|
|||
* Compute a hash of the given file contents.
|
||||
*/
|
||||
String _hash(String contents) {
|
||||
MD5 md5 = new MD5();
|
||||
md5.add(UTF8.encode(contents));
|
||||
return CryptoUtils.bytesToHex(md5.close());
|
||||
return hex.encode(md5.convert(UTF8.encode(contents)).bytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ environment:
|
|||
sdk: '>=1.12.0 <2.0.0'
|
||||
dependencies:
|
||||
args: '>=0.12.1 <0.14.0'
|
||||
crypto: ^0.9.0
|
||||
crypto: '>=0.9.2 <2.0.0'
|
||||
glob: ^1.0.3
|
||||
html: ^0.12.0
|
||||
package_config: ^0.1.1
|
||||
|
|
|
@ -80,12 +80,16 @@ testSameHash(String tmpDirPath) {
|
|||
if (dartExecutable == "") throw "dart executable not available";
|
||||
|
||||
// actions to take
|
||||
runAddHash() =>
|
||||
Process.runSync(dartExecutable,
|
||||
[path.join(dartRootPath, "tools", "addlatexhash.dart"),
|
||||
tmpPar8timesPath,
|
||||
hashPath,
|
||||
listPath]);
|
||||
runAddHash() {
|
||||
var args = [
|
||||
'--package-root=${Platform.packageRoot}',
|
||||
path.join(dartRootPath, "tools", "addlatexhash.dart"),
|
||||
tmpPar8timesPath,
|
||||
hashPath,
|
||||
listPath
|
||||
];
|
||||
return Process.runSync(dartExecutable, args);
|
||||
}
|
||||
|
||||
// perform test
|
||||
new File(par8timesPath).copySync(tmpPar8timesPath);
|
||||
|
@ -149,12 +153,16 @@ testSameDVI(String tmpDirPath) {
|
|||
runLatex(fileName,workingDirectory) =>
|
||||
Process.runSync("latex", [fileName], workingDirectory: workingDirectory);
|
||||
|
||||
runAddHash() =>
|
||||
Process.runSync(dartExecutable,
|
||||
[path.join(dartRootPath, "tools", "addlatexhash.dart"),
|
||||
tmpSpecPath,
|
||||
hashPath,
|
||||
listPath]);
|
||||
runAddHash() {
|
||||
var args = [
|
||||
'--package-root=${Platform.packageRoot}',
|
||||
path.join(dartRootPath, "tools", "addlatexhash.dart"),
|
||||
tmpSpecPath,
|
||||
hashPath,
|
||||
listPath
|
||||
];
|
||||
return Process.runSync(dartExecutable, args);
|
||||
}
|
||||
|
||||
runDvi2tty(dviFile) =>
|
||||
Process.runSync("dvi2tty", [dviFile], workingDirectory: tmpDirPath);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:convert/convert.dart";
|
||||
import "package:crypto/crypto.dart";
|
||||
import "package:expect/expect.dart";
|
||||
import 'dart:async';
|
||||
|
@ -31,9 +32,8 @@ class Server {
|
|||
String realm = "test";
|
||||
String username = "dart";
|
||||
String password = "password";
|
||||
var hasher = new MD5();
|
||||
hasher.add("${username}:${realm}:${password}".codeUnits);
|
||||
ha1 = CryptoUtils.bytesToHex(hasher.close());
|
||||
var hasher = md5.convert("${username}:${realm}:${password}".codeUnits);
|
||||
ha1 = hex.encode(hasher.bytes);
|
||||
|
||||
var nonce = "12345678"; // No need for random nonce in test.
|
||||
|
||||
|
@ -96,18 +96,17 @@ class Server {
|
|||
}
|
||||
Expect.isNotNull(header.parameters["response"]);
|
||||
|
||||
var hasher = new MD5();
|
||||
hasher.add("${request.method}:${uri}".codeUnits);
|
||||
var ha2 = CryptoUtils.bytesToHex(hasher.close());
|
||||
var hasher = md5.convert("${request.method}:${uri}".codeUnits);
|
||||
var ha2 = hex.encode(hasher.bytes);
|
||||
|
||||
var x;
|
||||
hasher = new MD5();
|
||||
Digest digest;
|
||||
if (qop == null || qop == "" || qop == "none") {
|
||||
hasher.add("$ha1:${nonce}:$ha2".codeUnits);
|
||||
digest = md5.convert("$ha1:${nonce}:$ha2".codeUnits);
|
||||
} else {
|
||||
hasher.add("$ha1:${nonce}:${nc}:${cnonce}:${qop}:$ha2".codeUnits);
|
||||
digest = md5.convert("$ha1:${nonce}:${nc}:${cnonce}:${qop}:$ha2".codeUnits);
|
||||
}
|
||||
Expect.equals(CryptoUtils.bytesToHex(hasher.close()),
|
||||
Expect.equals(hex.encode(digest.bytes),
|
||||
header.parameters["response"]);
|
||||
|
||||
successCount++;
|
||||
|
|
|
@ -42,7 +42,7 @@ class Server {
|
|||
List<String> tokens = authorization.split(" ");
|
||||
Expect.equals("Basic", tokens[0]);
|
||||
String auth =
|
||||
CryptoUtils.bytesToBase64(UTF8.encode("$username:$password"));
|
||||
BASE64.encode(UTF8.encode("$username:$password"));
|
||||
if (passwordChanged && auth != tokens[1]) {
|
||||
response.statusCode = HttpStatus.UNAUTHORIZED;
|
||||
response.headers.set(HttpHeaders.WWW_AUTHENTICATE,
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import "package:convert/convert.dart";
|
||||
import "package:crypto/crypto.dart";
|
||||
import "package:expect/expect.dart";
|
||||
import "package:path/path.dart";
|
||||
|
@ -115,9 +116,8 @@ class ProxyServer {
|
|||
authScheme = "Digest";
|
||||
|
||||
// Calculate ha1.
|
||||
var hasher = new MD5();
|
||||
hasher.add("${username}:${realm}:${password}".codeUnits);
|
||||
ha1 = CryptoUtils.bytesToHex(hasher.close());
|
||||
var digest = md5.convert("${username}:${realm}:${password}".codeUnits);
|
||||
ha1 = hex.encode(digest.bytes);
|
||||
}
|
||||
|
||||
basicAuthenticationRequired(request) {
|
||||
|
@ -173,7 +173,7 @@ class ProxyServer {
|
|||
List<String> tokens = authorization.split(" ");
|
||||
Expect.equals("Basic", tokens[0]);
|
||||
String auth =
|
||||
CryptoUtils.bytesToBase64(UTF8.encode("$username:$password"));
|
||||
BASE64.encode(UTF8.encode("$username:$password"));
|
||||
if (auth != tokens[1]) {
|
||||
basicAuthenticationRequired(request);
|
||||
return;
|
||||
|
@ -206,19 +206,17 @@ class ProxyServer {
|
|||
}
|
||||
Expect.isNotNull(header.parameters["response"]);
|
||||
|
||||
var hasher = new MD5();
|
||||
hasher.add("${request.method}:${uri}".codeUnits);
|
||||
var ha2 = CryptoUtils.bytesToHex(hasher.close());
|
||||
var digest = md5.convert("${request.method}:${uri}".codeUnits);
|
||||
var ha2 = hex.encode(digest.bytes);
|
||||
|
||||
var x;
|
||||
hasher = new MD5();
|
||||
if (qop == null || qop == "" || qop == "none") {
|
||||
hasher.add("$ha1:${nonce}:$ha2".codeUnits);
|
||||
digest = md5.convert("$ha1:${nonce}:$ha2".codeUnits);
|
||||
} else {
|
||||
hasher.add(
|
||||
digest = md5.convert(
|
||||
"$ha1:${nonce}:${nc}:${cnonce}:${qop}:$ha2".codeUnits);
|
||||
}
|
||||
Expect.equals(CryptoUtils.bytesToHex(hasher.close()),
|
||||
Expect.equals(hex.encode(digest.bytes),
|
||||
header.parameters["response"]);
|
||||
|
||||
// Add a bogus Proxy-Authentication-Info for testing.
|
||||
|
|
|
@ -173,7 +173,7 @@ class ProxyServer {
|
|||
List<String> tokens = authorization.split(" ");
|
||||
Expect.equals("Basic", tokens[0]);
|
||||
String auth =
|
||||
CryptoUtils.bytesToBase64(UTF8.encode("$username:$password"));
|
||||
BASE64.encode(UTF8.encode("$username:$password"));
|
||||
if (auth != tokens[1]) {
|
||||
basicAuthenticationRequired(request);
|
||||
return;
|
||||
|
|
|
@ -57,7 +57,7 @@ class SecurityConfiguration {
|
|||
for (int i = 0; i < 16; i++) {
|
||||
nonceData[i] = random.nextInt(256);
|
||||
}
|
||||
String nonce = CryptoUtils.bytesToBase64(nonceData);
|
||||
String nonce = BASE64.encode(nonceData);
|
||||
|
||||
uri = new Uri(
|
||||
scheme: uri.scheme == "wss" ? "https" : "http",
|
||||
|
@ -71,7 +71,7 @@ class SecurityConfiguration {
|
|||
if (uri.userInfo != null && !uri.userInfo.isEmpty) {
|
||||
// If the URL contains user information use that for basic
|
||||
// authorization.
|
||||
String auth = CryptoUtils.bytesToBase64(UTF8.encode(uri.userInfo));
|
||||
String auth = BASE64.encode(UTF8.encode(uri.userInfo));
|
||||
request.headers.set(HttpHeaders.AUTHORIZATION, "Basic $auth");
|
||||
}
|
||||
// Setup the initial handshake.
|
||||
|
@ -175,8 +175,8 @@ class SecurityConfiguration {
|
|||
Expect.equals('websocket', request.headers.value(HttpHeaders.UPGRADE));
|
||||
|
||||
var key = request.headers.value('Sec-WebSocket-Key');
|
||||
var sha1 = new SHA1()..add("$key$WEB_SOCKET_GUID".codeUnits);
|
||||
var accept = CryptoUtils.bytesToBase64(sha1.close());
|
||||
var digest = sha1.convert("$key$WEB_SOCKET_GUID".codeUnits);
|
||||
var accept = BASE64.encode(digest.bytes);
|
||||
request.response
|
||||
..statusCode = HttpStatus.SWITCHING_PROTOCOLS
|
||||
..headers.add(HttpHeaders.CONNECTION, "Upgrade")
|
||||
|
|
|
@ -13,6 +13,7 @@ import "dart:io";
|
|||
import "dart:typed_data";
|
||||
|
||||
import "package:async_helper/async_helper.dart";
|
||||
import "package:convert/convert.dart";
|
||||
import "package:crypto/crypto.dart";
|
||||
import "package:expect/expect.dart";
|
||||
import "package:path/path.dart";
|
||||
|
@ -467,8 +468,8 @@ class SecurityConfiguration {
|
|||
Expect.equals('websocket', request.headers.value(HttpHeaders.UPGRADE));
|
||||
|
||||
var key = request.headers.value('Sec-WebSocket-Key');
|
||||
var sha1 = new SHA1()..add("$key$WEB_SOCKET_GUID".codeUnits);
|
||||
var accept = CryptoUtils.bytesToBase64(sha1.close());
|
||||
var digest = sha1.convert("$key$WEB_SOCKET_GUID".codeUnits);
|
||||
var accept = BASE64.encode(digest.bytes);
|
||||
request.response
|
||||
..statusCode = HttpStatus.SWITCHING_PROTOCOLS
|
||||
..headers.add(HttpHeaders.CONNECTION, "Upgrade")
|
||||
|
@ -535,7 +536,7 @@ class SecurityConfiguration {
|
|||
server.listen((request) {
|
||||
Expect.isTrue(WebSocketTransformer.isUpgradeRequest(request));
|
||||
String auth =
|
||||
CryptoUtils.bytesToBase64(UTF8.encode(userInfo));
|
||||
BASE64.encode(UTF8.encode(userInfo));
|
||||
Expect.equals('Basic $auth', request.headers['Authorization'][0]);
|
||||
Expect.equals(1, request.headers['Authorization'].length);
|
||||
WebSocketTransformer.upgrade(request).then((webSocket) {
|
||||
|
|
|
@ -11,7 +11,9 @@
|
|||
// hash listing file name as the third argument. From docs/language a
|
||||
// typical usage would be as follows:
|
||||
//
|
||||
// dart ../../tools/addlatexhash.dart dartLangSpec.tex out.tex hash.txt
|
||||
// dart
|
||||
// --package-root=<build dir>/packages \
|
||||
// ../../tools/addlatexhash.dart dartLangSpec.tex out.tex hash.txt
|
||||
//
|
||||
// This will produce a normalized variant out.tex of the language
|
||||
// specification with hash values filled in, and a listing hash.txt of
|
||||
|
@ -24,8 +26,10 @@
|
|||
|
||||
import 'dart:io';
|
||||
import 'dart:convert';
|
||||
import '../third_party/pkg/utf/lib/utf.dart';
|
||||
import '../third_party/pkg/crypto/lib/crypto.dart';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:convert/convert.dart';
|
||||
import 'package:utf/utf.dart';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Normalization of the text: removal or normalization of parts that
|
||||
|
@ -484,16 +488,15 @@ gatherLines(lines, startIndex, nextIndex) =>
|
|||
/// in [lines], stopping just before [nextIndex]. SIDE EFFECT:
|
||||
/// Outputs the simplified text and its hash value to [listSink].
|
||||
computeHashValue(lines, startIndex, nextIndex, listSink) {
|
||||
final hashEncoder = new SHA1();
|
||||
final gatheredLine = gatherLines(lines, startIndex, nextIndex);
|
||||
final simplifiedLine = simplifyLine(gatheredLine);
|
||||
listSink.write(" % $simplifiedLine\n");
|
||||
hashEncoder.add(encodeUtf8(simplifiedLine));
|
||||
return hashEncoder.close();
|
||||
var digest = sha1.convert(encodeUtf8(simplifiedLine));
|
||||
return digest.bytes;
|
||||
}
|
||||
|
||||
computeHashString(lines, startIndex, nextIndex, listSink) =>
|
||||
CryptoUtils.bytesToHex(computeHashValue(lines,
|
||||
hex.encode(computeHashValue(lines,
|
||||
startIndex,
|
||||
nextIndex,
|
||||
listSink));
|
||||
|
|
Loading…
Reference in a new issue