Imported Upstream version 6.0.1+r55
Chirayu Desai
7 years ago
0 | Manifest-Version: 2.0 | |
1 | Class-Path: dom3-xml-apis.jar dom3-xercesImpl.jar xmlParserAPIs.jar x | |
2 | ercesImpl.jar xerces.jar xml4j.jar xmlparserv2.jar crimson.jar parser | |
3 | .jar jaxp.jar xml-apis.jar gnujaxp.jar dom4j-full.jar batik-svg-dom.j | |
4 | ar crimson-parser.jar avalon-run.jar | |
5 | Created-By: 1.4.2_04 (Sun Microsystems Inc.) | |
6 | Main-Class: org.w3c.domts.level2.core.alltests | |
7 | ||
8 | Name: org/w3c/domts/level2/core | |
9 | Implementation-Title: W3C/NIST Test Suite for DOM Level 2 Core | |
10 | Specification-Title: W3C/NIST Test Suite for DOM Level 2 Core | |
11 | Specification-Version: 0.0.1 | |
12 | Specification-Vendor: World Wide Web Consortium | |
13 | Implementation-Version: 0.0.1 | |
14 | Implementation-Vendor: World Wide Web Consortium | |
15 | ||
0 | Manifest-Version: 2.0 | |
1 | Class-Path: dom3-xml-apis.jar dom3-xercesImpl.jar xmlParserAPIs.jar x | |
2 | ercesImpl.jar xerces.jar xml4j.jar xmlparserv2.jar crimson.jar parser | |
3 | .jar jaxp.jar xml-apis.jar gnujaxp.jar dom4j-full.jar batik-svg-dom.j | |
4 | ar crimson-parser.jar avalon-run.jar | |
5 | Created-By: 1.4.2_04 (Sun Microsystems Inc.) | |
6 | Main-Class: org.w3c.domts.level2.core.alltests | |
7 | ||
8 | Name: org/w3c/domts/level2/core | |
9 | Implementation-Title: W3C/NIST Test Suite for DOM Level 2 Core | |
10 | Specification-Title: W3C/NIST Test Suite for DOM Level 2 Core | |
11 | Specification-Version: 0.0.1 | |
12 | Specification-Vendor: World Wide Web Consortium | |
13 | Implementation-Version: 0.0.1 | |
14 | Implementation-Vendor: World Wide Web Consortium | |
15 |
0 | <!-- JUnit build script using ant 1.3 --> | |
1 | <project name="junit" default="dist" basedir="."> | |
2 | <target name="init"> | |
3 | <tstamp/> | |
4 | <property name="version" value="3.7" /> | |
5 | <property name="dist" value="junit${version}" /> | |
6 | <property name="versionfile" value="junit/runner/Version.java" /> | |
7 | <property name="zipfile" value="${dist}.zip" /> | |
8 | </target> | |
9 | ||
10 | <target name="versiontag" depends="init"> | |
11 | <filter token="version" value="${version}" /> | |
12 | <copy | |
13 | file="${versionfile}" | |
14 | tofile="${versionfile}tmp" | |
15 | filtering="on" | |
16 | /> | |
17 | <move file="${versionfile}tmp" tofile="${versionfile}" /> | |
18 | </target> | |
19 | ||
20 | <target name="build" depends="versiontag"> | |
21 | <javac | |
22 | srcdir="." | |
23 | destdir="." | |
24 | debug="on" | |
25 | /> | |
26 | </target> | |
27 | ||
28 | <target name="dist" depends="build"> | |
29 | <delete dir="${dist}" /> | |
30 | <mkdir dir="${dist}" /> | |
31 | <jar | |
32 | jarfile="${dist}/src.jar" | |
33 | basedir="." | |
34 | excludes="${dist}/src.jar, junit/tests/**, junit/samples/**, **/*.class, doc/**, README.html, build.xml" | |
35 | /> | |
36 | <jar | |
37 | jarfile="${dist}/junit.jar" | |
38 | basedir="." | |
39 | excludes="${dist}/junit.jar, junit/tests/**, junit/samples/**, **/*.java, doc/**, README.html, jar-manifest.txt" | |
40 | /> | |
41 | <copy todir="${dist}/junit/samples"> | |
42 | <fileset dir="junit/samples" /> | |
43 | </copy> | |
44 | <copy todir="${dist}/junit/tests"> | |
45 | <fileset dir="junit/tests" /> | |
46 | </copy> | |
47 | <delete file="${dist}/junit/tests/test.jar"/> | |
48 | <jar | |
49 | jarfile="${dist}/junit/tests/test.jar" | |
50 | basedir="." | |
51 | includes="junit/tests/LoadedFromJar.class" | |
52 | /> | |
53 | <mkdir dir="${dist}/javadoc" /> | |
54 | <javadoc | |
55 | sourcepath="." | |
56 | packagenames="junit.framework.*, junit.extensions.*" | |
57 | destdir="${dist}/javadoc" | |
58 | author="false" | |
59 | version="false" | |
60 | use="false" | |
61 | windowtitle="JUnit API" | |
62 | /> | |
63 | <copy todir="${dist}/doc"> | |
64 | <fileset dir="doc"/> | |
65 | </copy> | |
66 | <copy file="README.html" tofile="${dist}/README.html" /> | |
67 | ||
68 | <java classname="junit.textui.TestRunner" fork="yes"> | |
69 | <arg value="junit.samples.AllTests" /> | |
70 | <classpath> | |
71 | <pathelement location="${dist}" /> | |
72 | <pathelement location="${dist}/junit.jar" /> | |
73 | </classpath> | |
74 | </java> | |
75 | </target> | |
76 | ||
77 | <target name="zip"> | |
78 | <!-- !!! hard code names, variable substitution doesn't work !!! --> | |
79 | <zip | |
80 | zipfile="junit3.6.zip" | |
81 | basedir="." | |
82 | includes="junit3.6/**" | |
83 | /> | |
84 | </target> | |
85 | ||
86 | <target name="awtui" depends="dist"> | |
87 | <java classname="junit.awtui.TestRunner" fork="yes"> | |
88 | <arg value="junit.samples.AllTests" /> | |
89 | <classpath> | |
90 | <pathelement location="${dist}" /> | |
91 | <pathelement location="${dist}/junit.jar" /> | |
92 | </classpath> | |
93 | </java> | |
94 | </target> | |
95 | ||
96 | <target name="swingui" depends="dist"> | |
97 | <java classname="junit.swingui.TestRunner" fork="yes"> | |
98 | <arg value="junit.samples.AllTests" /> | |
99 | <classpath> | |
100 | <pathelement location="${dist}" /> | |
101 | <pathelement location="${dist}/junit.jar" /> | |
102 | </classpath> | |
103 | </java> | |
104 | </target> | |
105 | </project> | |
0 | <!-- JUnit build script using ant 1.3 --> | |
1 | <project name="junit" default="dist" basedir="."> | |
2 | <target name="init"> | |
3 | <tstamp/> | |
4 | <property name="version" value="3.7" /> | |
5 | <property name="dist" value="junit${version}" /> | |
6 | <property name="versionfile" value="junit/runner/Version.java" /> | |
7 | <property name="zipfile" value="${dist}.zip" /> | |
8 | </target> | |
9 | ||
10 | <target name="versiontag" depends="init"> | |
11 | <filter token="version" value="${version}" /> | |
12 | <copy | |
13 | file="${versionfile}" | |
14 | tofile="${versionfile}tmp" | |
15 | filtering="on" | |
16 | /> | |
17 | <move file="${versionfile}tmp" tofile="${versionfile}" /> | |
18 | </target> | |
19 | ||
20 | <target name="build" depends="versiontag"> | |
21 | <javac | |
22 | srcdir="." | |
23 | destdir="." | |
24 | debug="on" | |
25 | /> | |
26 | </target> | |
27 | ||
28 | <target name="dist" depends="build"> | |
29 | <delete dir="${dist}" /> | |
30 | <mkdir dir="${dist}" /> | |
31 | <jar | |
32 | jarfile="${dist}/src.jar" | |
33 | basedir="." | |
34 | excludes="${dist}/src.jar, junit/tests/**, junit/samples/**, **/*.class, doc/**, README.html, build.xml" | |
35 | /> | |
36 | <jar | |
37 | jarfile="${dist}/junit.jar" | |
38 | basedir="." | |
39 | excludes="${dist}/junit.jar, junit/tests/**, junit/samples/**, **/*.java, doc/**, README.html, jar-manifest.txt" | |
40 | /> | |
41 | <copy todir="${dist}/junit/samples"> | |
42 | <fileset dir="junit/samples" /> | |
43 | </copy> | |
44 | <copy todir="${dist}/junit/tests"> | |
45 | <fileset dir="junit/tests" /> | |
46 | </copy> | |
47 | <delete file="${dist}/junit/tests/test.jar"/> | |
48 | <jar | |
49 | jarfile="${dist}/junit/tests/test.jar" | |
50 | basedir="." | |
51 | includes="junit/tests/LoadedFromJar.class" | |
52 | /> | |
53 | <mkdir dir="${dist}/javadoc" /> | |
54 | <javadoc | |
55 | sourcepath="." | |
56 | packagenames="junit.framework.*, junit.extensions.*" | |
57 | destdir="${dist}/javadoc" | |
58 | author="false" | |
59 | version="false" | |
60 | use="false" | |
61 | windowtitle="JUnit API" | |
62 | /> | |
63 | <copy todir="${dist}/doc"> | |
64 | <fileset dir="doc"/> | |
65 | </copy> | |
66 | <copy file="README.html" tofile="${dist}/README.html" /> | |
67 | ||
68 | <java classname="junit.textui.TestRunner" fork="yes"> | |
69 | <arg value="junit.samples.AllTests" /> | |
70 | <classpath> | |
71 | <pathelement location="${dist}" /> | |
72 | <pathelement location="${dist}/junit.jar" /> | |
73 | </classpath> | |
74 | </java> | |
75 | </target> | |
76 | ||
77 | <target name="zip"> | |
78 | <!-- !!! hard code names, variable substitution doesn't work !!! --> | |
79 | <zip | |
80 | zipfile="junit3.6.zip" | |
81 | basedir="." | |
82 | includes="junit3.6/**" | |
83 | /> | |
84 | </target> | |
85 | ||
86 | <target name="awtui" depends="dist"> | |
87 | <java classname="junit.awtui.TestRunner" fork="yes"> | |
88 | <arg value="junit.samples.AllTests" /> | |
89 | <classpath> | |
90 | <pathelement location="${dist}" /> | |
91 | <pathelement location="${dist}/junit.jar" /> | |
92 | </classpath> | |
93 | </java> | |
94 | </target> | |
95 | ||
96 | <target name="swingui" depends="dist"> | |
97 | <java classname="junit.swingui.TestRunner" fork="yes"> | |
98 | <arg value="junit.samples.AllTests" /> | |
99 | <classpath> | |
100 | <pathelement location="${dist}" /> | |
101 | <pathelement location="${dist}/junit.jar" /> | |
102 | </classpath> | |
103 | </java> | |
104 | </target> | |
105 | </project> |
0 | <?xml version="1.0"?><?TEST-STYLE PIDATA?> | |
1 | <!DOCTYPE svg SYSTEM "staff2.dtd" []> | |
2 | <!-- This is comment number 1.--> | |
3 | <svg xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="100" height="100"/><script type="text/ecmascript">&svgtest;&svgunit;</script> | |
4 | <employee xmlns="http://www.example.com"> | |
5 | <employeeId>EMP0001</employeeId> | |
6 | <name>Margaret Martin</name> | |
7 | <position>Accountant</position> | |
8 | <salary>56,000</salary> | |
9 | <gender>Female</gender> | |
10 | <address>1230 North Ave. Dallas, Texas 98551</address> | |
11 | </employee> | |
12 | </svg> | |
0 | <?xml version="1.0"?><?TEST-STYLE PIDATA?> | |
1 | <!DOCTYPE svg SYSTEM "staff2.dtd" []> | |
2 | <!-- This is comment number 1.--> | |
3 | <svg xmlns="http://www.w3.org/2000/svg"><rect x="0" y="0" width="100" height="100"/><script type="text/ecmascript">&svgtest;&svgunit;</script> | |
4 | <employee xmlns="http://www.example.com"> | |
5 | <employeeId>EMP0001</employeeId> | |
6 | <name>Margaret Martin</name> | |
7 | <position>Accountant</position> | |
8 | <salary>56,000</salary> | |
9 | <gender>Female</gender> | |
10 | <address>1230 North Ave. Dallas, Texas 98551</address> | |
11 | </employee> | |
12 | </svg> |
0 | <!-- | |
1 | ||
2 | Copyright (c) 2001-2004 World Wide Web Consortium, | |
3 | (Massachusetts Institute of Technology, Institut National de | |
4 | Recherche en Informatique et en Automatique, Keio University). All | |
5 | Rights Reserved. This program is distributed under the W3C's Software | |
6 | Intellectual Property License. This program is distributed in the | |
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
9 | PURPOSE. | |
10 | ||
11 | See W3C License http://www.w3.org/Consortium/Legal/ for more details. | |
12 | ||
13 | --> | |
14 | ||
15 | <!-- | |
16 | ||
17 | This is a radically simplified DTD for use in the DOM Test Suites | |
18 | due to a XML non-conformance of one implementation in processing | |
19 | parameter entities. When that non-conformance is resolved, | |
20 | this DTD can be replaced by the normal DTD for XHTML. | |
21 | ||
22 | --> | |
23 | ||
24 | ||
25 | <!ELEMENT html (head, body)> | |
26 | <!ATTLIST html xmlns CDATA #IMPLIED> | |
27 | <!ELEMENT head (meta,title,script*)> | |
28 | <!ELEMENT meta EMPTY> | |
29 | <!ATTLIST meta | |
30 | http-equiv CDATA #IMPLIED | |
31 | content CDATA #IMPLIED> | |
32 | <!ELEMENT title (#PCDATA)> | |
33 | <!ELEMENT body (p*)> | |
34 | <!ATTLIST body onload CDATA #IMPLIED> | |
35 | <!ELEMENT p (#PCDATA|em|strong|code|sup|var|acronym|abbr)*> | |
36 | <!ATTLIST p | |
37 | xmlns:dmstc CDATA #IMPLIED | |
38 | xmlns:nm CDATA #IMPLIED | |
39 | xmlns:emp2 CDATA #IMPLIED | |
40 | id ID #IMPLIED | |
41 | > | |
42 | <!ELEMENT em (#PCDATA)> | |
43 | <!ELEMENT span (#PCDATA)> | |
44 | <!ELEMENT strong (#PCDATA)> | |
45 | <!ELEMENT code (#PCDATA)> | |
46 | <!ELEMENT sup (#PCDATA)> | |
47 | <!ELEMENT var (#PCDATA|span)*> | |
48 | <!ELEMENT acronym (#PCDATA)> | |
49 | <!ATTLIST acronym | |
50 | title CDATA #IMPLIED | |
51 | class CDATA #IMPLIED | |
52 | id ID #IMPLIED | |
53 | > | |
54 | <!ELEMENT abbr (#PCDATA)> | |
55 | <!ATTLIST abbr | |
56 | title CDATA #IMPLIED | |
57 | class CDATA #IMPLIED | |
58 | id ID #IMPLIED | |
59 | > | |
60 | <!ELEMENT script (#PCDATA)> | |
61 | <!ATTLIST script | |
62 | type CDATA #IMPLIED | |
63 | src CDATA #IMPLIED | |
64 | charset CDATA #IMPLIED> | |
0 | <!-- | |
1 | ||
2 | Copyright (c) 2001-2004 World Wide Web Consortium, | |
3 | (Massachusetts Institute of Technology, Institut National de | |
4 | Recherche en Informatique et en Automatique, Keio University). All | |
5 | Rights Reserved. This program is distributed under the W3C's Software | |
6 | Intellectual Property License. This program is distributed in the | |
7 | hope that it will be useful, but WITHOUT ANY WARRANTY; without even | |
8 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
9 | PURPOSE. | |
10 | ||
11 | See W3C License http://www.w3.org/Consortium/Legal/ for more details. | |
12 | ||
13 | --> | |
14 | ||
15 | <!-- | |
16 | ||
17 | This is a radically simplified DTD for use in the DOM Test Suites | |
18 | due to a XML non-conformance of one implementation in processing | |
19 | parameter entities. When that non-conformance is resolved, | |
20 | this DTD can be replaced by the normal DTD for XHTML. | |
21 | ||
22 | --> | |
23 | ||
24 | ||
25 | <!ELEMENT html (head, body)> | |
26 | <!ATTLIST html xmlns CDATA #IMPLIED> | |
27 | <!ELEMENT head (meta,title,script*)> | |
28 | <!ELEMENT meta EMPTY> | |
29 | <!ATTLIST meta | |
30 | http-equiv CDATA #IMPLIED | |
31 | content CDATA #IMPLIED> | |
32 | <!ELEMENT title (#PCDATA)> | |
33 | <!ELEMENT body (p*)> | |
34 | <!ATTLIST body onload CDATA #IMPLIED> | |
35 | <!ELEMENT p (#PCDATA|em|strong|code|sup|var|acronym|abbr)*> | |
36 | <!ATTLIST p | |
37 | xmlns:dmstc CDATA #IMPLIED | |
38 | xmlns:nm CDATA #IMPLIED | |
39 | xmlns:emp2 CDATA #IMPLIED | |
40 | id ID #IMPLIED | |
41 | > | |
42 | <!ELEMENT em (#PCDATA)> | |
43 | <!ELEMENT span (#PCDATA)> | |
44 | <!ELEMENT strong (#PCDATA)> | |
45 | <!ELEMENT code (#PCDATA)> | |
46 | <!ELEMENT sup (#PCDATA)> | |
47 | <!ELEMENT var (#PCDATA|span)*> | |
48 | <!ELEMENT acronym (#PCDATA)> | |
49 | <!ATTLIST acronym | |
50 | title CDATA #IMPLIED | |
51 | class CDATA #IMPLIED | |
52 | id ID #IMPLIED | |
53 | > | |
54 | <!ELEMENT abbr (#PCDATA)> | |
55 | <!ATTLIST abbr | |
56 | title CDATA #IMPLIED | |
57 | class CDATA #IMPLIED | |
58 | id ID #IMPLIED | |
59 | > | |
60 | <!ELEMENT script (#PCDATA)> | |
61 | <!ATTLIST script | |
62 | type CDATA #IMPLIED | |
63 | src CDATA #IMPLIED | |
64 | charset CDATA #IMPLIED> |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | /* A bogus doc file used to see if we can detect | |
18 | * file type based on its file extension. | |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | /* A bogus doc file used to see if we can detect | |
18 | * file type based on its file extension. | |
19 | 19 | */⏎ |
0 | <html> | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
4 | * contributor license agreements. See the NOTICE file distributed with | |
5 | * this work for additional information regarding copyright ownership. | |
6 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
7 | * (the "License"); you may not use this file except in compliance with | |
8 | * the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | * See the License for the specific language governing permissions and | |
16 | * limitations under the License. | |
17 | */ | |
18 | ||
19 | /* A bogus html file used to see if we can detect | |
20 | * file type based on its file extension / content. | |
0 | <html> | |
1 | ||
2 | /* | |
3 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
4 | * contributor license agreements. See the NOTICE file distributed with | |
5 | * this work for additional information regarding copyright ownership. | |
6 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
7 | * (the "License"); you may not use this file except in compliance with | |
8 | * the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | * See the License for the specific language governing permissions and | |
16 | * limitations under the License. | |
17 | */ | |
18 | ||
19 | /* A bogus html file used to see if we can detect | |
20 | * file type based on its file extension / content. | |
21 | 21 | */⏎ |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | /* A bogus RTF file used to see if we can detect | |
18 | * file type based on its file extension. | |
0 | /* | |
1 | * Licensed to the Apache Software Foundation (ASF) under one or more | |
2 | * contributor license agreements. See the NOTICE file distributed with | |
3 | * this work for additional information regarding copyright ownership. | |
4 | * The ASF licenses this file to You under the Apache License, Version 2.0 | |
5 | * (the "License"); you may not use this file except in compliance with | |
6 | * the License. You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | ||
17 | /* A bogus RTF file used to see if we can detect | |
18 | * file type based on its file extension. | |
19 | 19 | */⏎ |
0 | /** | |
1 | ******************************************************************************* | |
2 | * Copyright (C) 2003-2008, International Business Machines Corporation and | |
3 | * others. All Rights Reserved. | |
4 | ******************************************************************************* | |
5 | * Partial port from ICU4C's Grego class in i18n/gregoimp.h. | |
6 | * | |
7 | * Methods ported, or moved here from OlsonTimeZone, initially | |
8 | * for work on Jitterbug 5470: | |
9 | * tzdata2006n Brazil incorrect fall-back date 2009-mar-01 | |
10 | * Only the methods necessary for that work are provided - this is not a full | |
11 | * port of ICU4C's Grego class (yet). | |
12 | * | |
13 | * These utilities are used by both OlsonTimeZone and SimpleTimeZone. | |
14 | */ | |
15 | ||
16 | package java.util; // android-changed: com.ibm.icu.impl (ICU4J 4.2) | |
17 | ||
18 | // android-changed: import com.ibm.icu.util.Calendar; | |
19 | ||
20 | /** | |
21 | * A utility class providing proleptic Gregorian calendar functions | |
22 | * used by time zone and calendar code. Do not instantiate. | |
23 | * | |
24 | * Note: Unlike GregorianCalendar, all computations performed by this | |
25 | * class occur in the pure proleptic GregorianCalendar. | |
26 | */ | |
27 | // android-changed: public | |
28 | class Grego { | |
29 | ||
30 | // Max/min milliseconds | |
31 | public static final long MIN_MILLIS = -184303902528000000L; | |
32 | public static final long MAX_MILLIS = 183882168921600000L; | |
33 | ||
34 | public static final int MILLIS_PER_SECOND = 1000; | |
35 | public static final int MILLIS_PER_MINUTE = 60*MILLIS_PER_SECOND; | |
36 | public static final int MILLIS_PER_HOUR = 60*MILLIS_PER_MINUTE; | |
37 | public static final int MILLIS_PER_DAY = 24*MILLIS_PER_HOUR; | |
38 | ||
39 | // January 1, 1 CE Gregorian | |
40 | private static final int JULIAN_1_CE = 1721426; | |
41 | ||
42 | // January 1, 1970 CE Gregorian | |
43 | private static final int JULIAN_1970_CE = 2440588; | |
44 | ||
45 | private static final int[] MONTH_LENGTH = new int[] { | |
46 | 31,28,31,30,31,30,31,31,30,31,30,31, | |
47 | 31,29,31,30,31,30,31,31,30,31,30,31 | |
48 | }; | |
49 | ||
50 | private static final int[] DAYS_BEFORE = new int[] { | |
51 | 0,31,59,90,120,151,181,212,243,273,304,334, | |
52 | 0,31,60,91,121,152,182,213,244,274,305,335 }; | |
53 | ||
54 | /** | |
55 | * Return true if the given year is a leap year. | |
56 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
57 | * @return true if the year is a leap year | |
58 | */ | |
59 | public static final boolean isLeapYear(int year) { | |
60 | // year&0x3 == year%4 | |
61 | return ((year&0x3) == 0) && ((year%100 != 0) || (year%400 == 0)); | |
62 | } | |
63 | ||
64 | /** | |
65 | * Return the number of days in the given month. | |
66 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
67 | * @param month 0-based month, with 0==Jan | |
68 | * @return the number of days in the given month | |
69 | */ | |
70 | public static final int monthLength(int year, int month) { | |
71 | return MONTH_LENGTH[month + (isLeapYear(year) ? 12 : 0)]; | |
72 | } | |
73 | ||
74 | /** | |
75 | * Return the length of a previous month of the Gregorian calendar. | |
76 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
77 | * @param month 0-based month, with 0==Jan | |
78 | * @return the number of days in the month previous to the given month | |
79 | */ | |
80 | public static final int previousMonthLength(int year, int month) { | |
81 | return (month > 0) ? monthLength(year, month-1) : 31; | |
82 | } | |
83 | ||
84 | /** | |
85 | * Convert a year, month, and day-of-month, given in the proleptic | |
86 | * Gregorian calendar, to 1970 epoch days. | |
87 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
88 | * @param month 0-based month, with 0==Jan | |
89 | * @param dom 1-based day of month | |
90 | * @return the day number, with day 0 == Jan 1 1970 | |
91 | */ | |
92 | public static long fieldsToDay(int year, int month, int dom) { | |
93 | int y = year - 1; | |
94 | long julian = | |
95 | 365 * y + floorDivide(y, 4) + (JULIAN_1_CE - 3) + // Julian cal | |
96 | floorDivide(y, 400) - floorDivide(y, 100) + 2 + // => Gregorian cal | |
97 | DAYS_BEFORE[month + (isLeapYear(year) ? 12 : 0)] + dom; // => month/dom | |
98 | return julian - JULIAN_1970_CE; // JD => epoch day | |
99 | } | |
100 | ||
101 | /** | |
102 | * Return the day of week on the 1970-epoch day | |
103 | * @param day the 1970-epoch day (integral value) | |
104 | * @return the day of week | |
105 | */ | |
106 | public static int dayOfWeek(long day) { | |
107 | long[] remainder = new long[1]; | |
108 | floorDivide(day + Calendar.THURSDAY, 7, remainder); | |
109 | int dayOfWeek = (int)remainder[0]; | |
110 | dayOfWeek = (dayOfWeek == 0) ? 7 : dayOfWeek; | |
111 | return dayOfWeek; | |
112 | } | |
113 | ||
114 | public static int[] dayToFields(long day, int[] fields) { | |
115 | if (fields == null || fields.length < 5) { | |
116 | fields = new int[5]; | |
117 | } | |
118 | // Convert from 1970 CE epoch to 1 CE epoch (Gregorian calendar) | |
119 | day += JULIAN_1970_CE - JULIAN_1_CE; | |
120 | ||
121 | long[] rem = new long[1]; | |
122 | long n400 = floorDivide(day, 146097, rem); | |
123 | long n100 = floorDivide(rem[0], 36524, rem); | |
124 | long n4 = floorDivide(rem[0], 1461, rem); | |
125 | long n1 = floorDivide(rem[0], 365, rem); | |
126 | ||
127 | int year = (int)(400 * n400 + 100 * n100 + 4 * n4 + n1); | |
128 | int dayOfYear = (int)rem[0]; | |
129 | if (n100 == 4 || n1 == 4) { | |
130 | dayOfYear = 365; // Dec 31 at end of 4- or 400-yr cycle | |
131 | } | |
132 | else { | |
133 | ++year; | |
134 | } | |
135 | ||
136 | boolean isLeap = isLeapYear(year); | |
137 | int correction = 0; | |
138 | int march1 = isLeap ? 60 : 59; // zero-based DOY for March 1 | |
139 | if (dayOfYear >= march1) { | |
140 | correction = isLeap ? 1 : 2; | |
141 | } | |
142 | int month = (12 * (dayOfYear + correction) + 6) / 367; // zero-based month | |
143 | int dayOfMonth = dayOfYear - DAYS_BEFORE[isLeap ? month + 12 : month] + 1; // one-based DOM | |
144 | int dayOfWeek = (int)((day + 2) % 7); // day 0 is Monday(2) | |
145 | if (dayOfWeek < 1 /* Sunday */) { | |
146 | dayOfWeek += 7; | |
147 | } | |
148 | dayOfYear++; // 1-based day of year | |
149 | ||
150 | fields[0] = year; | |
151 | fields[1] = month; | |
152 | fields[2] = dayOfMonth; | |
153 | fields[3] = dayOfWeek; | |
154 | fields[4] = dayOfYear; | |
155 | ||
156 | return fields; | |
157 | } | |
158 | ||
159 | /* | |
160 | * Convert long time to date/time fields | |
161 | * | |
162 | * result[0] : year | |
163 | * result[1] : month | |
164 | * result[2] : dayOfMonth | |
165 | * result[3] : dayOfWeek | |
166 | * result[4] : dayOfYear | |
167 | * result[5] : millisecond in day | |
168 | */ | |
169 | public static int[] timeToFields(long time, int[] fields) { | |
170 | if (fields == null || fields.length < 6) { | |
171 | fields = new int[6]; | |
172 | } | |
173 | long[] remainder = new long[1]; | |
174 | long day = floorDivide(time, 24*60*60*1000 /* milliseconds per day */, remainder); | |
175 | dayToFields(day, fields); | |
176 | fields[5] = (int)remainder[0]; | |
177 | return fields; | |
178 | } | |
179 | ||
180 | public static long floorDivide(long numerator, long denominator) { | |
181 | // We do this computation in order to handle | |
182 | // a numerator of Long.MIN_VALUE correctly | |
183 | return (numerator >= 0) ? | |
184 | numerator / denominator : | |
185 | ((numerator + 1) / denominator) - 1; | |
186 | } | |
187 | ||
188 | private static long floorDivide(long numerator, long denominator, long[] remainder) { | |
189 | if (numerator >= 0) { | |
190 | remainder[0] = numerator % denominator; | |
191 | return numerator / denominator; | |
192 | } | |
193 | long quotient = ((numerator + 1) / denominator) - 1; | |
194 | remainder[0] = numerator - (quotient * denominator); | |
195 | return quotient; | |
196 | } | |
197 | ||
198 | /* | |
199 | * Returns the ordinal number for the specified day of week in the month. | |
200 | * The valid return value is 1, 2, 3, 4 or -1. | |
201 | */ | |
202 | public static int getDayOfWeekInMonth(int year, int month, int dayOfMonth) { | |
203 | int weekInMonth = (dayOfMonth + 6)/7; | |
204 | if (weekInMonth == 4) { | |
205 | if (dayOfMonth + 7 > monthLength(year, month)) { | |
206 | weekInMonth = -1; | |
207 | } | |
208 | } else if (weekInMonth == 5) { | |
209 | weekInMonth = -1; | |
210 | } | |
211 | return weekInMonth; | |
212 | } | |
213 | } | |
0 | /** | |
1 | ******************************************************************************* | |
2 | * Copyright (C) 2003-2008, International Business Machines Corporation and | |
3 | * others. All Rights Reserved. | |
4 | ******************************************************************************* | |
5 | * Partial port from ICU4C's Grego class in i18n/gregoimp.h. | |
6 | * | |
7 | * Methods ported, or moved here from OlsonTimeZone, initially | |
8 | * for work on Jitterbug 5470: | |
9 | * tzdata2006n Brazil incorrect fall-back date 2009-mar-01 | |
10 | * Only the methods necessary for that work are provided - this is not a full | |
11 | * port of ICU4C's Grego class (yet). | |
12 | * | |
13 | * These utilities are used by both OlsonTimeZone and SimpleTimeZone. | |
14 | */ | |
15 | ||
16 | package java.util; // android-changed: com.ibm.icu.impl (ICU4J 4.2) | |
17 | ||
18 | // android-changed: import com.ibm.icu.util.Calendar; | |
19 | ||
20 | /** | |
21 | * A utility class providing proleptic Gregorian calendar functions | |
22 | * used by time zone and calendar code. Do not instantiate. | |
23 | * | |
24 | * Note: Unlike GregorianCalendar, all computations performed by this | |
25 | * class occur in the pure proleptic GregorianCalendar. | |
26 | */ | |
27 | // android-changed: public | |
28 | class Grego { | |
29 | ||
30 | // Max/min milliseconds | |
31 | public static final long MIN_MILLIS = -184303902528000000L; | |
32 | public static final long MAX_MILLIS = 183882168921600000L; | |
33 | ||
34 | public static final int MILLIS_PER_SECOND = 1000; | |
35 | public static final int MILLIS_PER_MINUTE = 60*MILLIS_PER_SECOND; | |
36 | public static final int MILLIS_PER_HOUR = 60*MILLIS_PER_MINUTE; | |
37 | public static final int MILLIS_PER_DAY = 24*MILLIS_PER_HOUR; | |
38 | ||
39 | // January 1, 1 CE Gregorian | |
40 | private static final int JULIAN_1_CE = 1721426; | |
41 | ||
42 | // January 1, 1970 CE Gregorian | |
43 | private static final int JULIAN_1970_CE = 2440588; | |
44 | ||
45 | private static final int[] MONTH_LENGTH = new int[] { | |
46 | 31,28,31,30,31,30,31,31,30,31,30,31, | |
47 | 31,29,31,30,31,30,31,31,30,31,30,31 | |
48 | }; | |
49 | ||
50 | private static final int[] DAYS_BEFORE = new int[] { | |
51 | 0,31,59,90,120,151,181,212,243,273,304,334, | |
52 | 0,31,60,91,121,152,182,213,244,274,305,335 }; | |
53 | ||
54 | /** | |
55 | * Return true if the given year is a leap year. | |
56 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
57 | * @return true if the year is a leap year | |
58 | */ | |
59 | public static final boolean isLeapYear(int year) { | |
60 | // year&0x3 == year%4 | |
61 | return ((year&0x3) == 0) && ((year%100 != 0) || (year%400 == 0)); | |
62 | } | |
63 | ||
64 | /** | |
65 | * Return the number of days in the given month. | |
66 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
67 | * @param month 0-based month, with 0==Jan | |
68 | * @return the number of days in the given month | |
69 | */ | |
70 | public static final int monthLength(int year, int month) { | |
71 | return MONTH_LENGTH[month + (isLeapYear(year) ? 12 : 0)]; | |
72 | } | |
73 | ||
74 | /** | |
75 | * Return the length of a previous month of the Gregorian calendar. | |
76 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
77 | * @param month 0-based month, with 0==Jan | |
78 | * @return the number of days in the month previous to the given month | |
79 | */ | |
80 | public static final int previousMonthLength(int year, int month) { | |
81 | return (month > 0) ? monthLength(year, month-1) : 31; | |
82 | } | |
83 | ||
84 | /** | |
85 | * Convert a year, month, and day-of-month, given in the proleptic | |
86 | * Gregorian calendar, to 1970 epoch days. | |
87 | * @param year Gregorian year, with 0 == 1 BCE, -1 == 2 BCE, etc. | |
88 | * @param month 0-based month, with 0==Jan | |
89 | * @param dom 1-based day of month | |
90 | * @return the day number, with day 0 == Jan 1 1970 | |
91 | */ | |
92 | public static long fieldsToDay(int year, int month, int dom) { | |
93 | int y = year - 1; | |
94 | long julian = | |
95 | 365 * y + floorDivide(y, 4) + (JULIAN_1_CE - 3) + // Julian cal | |
96 | floorDivide(y, 400) - floorDivide(y, 100) + 2 + // => Gregorian cal | |
97 | DAYS_BEFORE[month + (isLeapYear(year) ? 12 : 0)] + dom; // => month/dom | |
98 | return julian - JULIAN_1970_CE; // JD => epoch day | |
99 | } | |
100 | ||
101 | /** | |
102 | * Return the day of week on the 1970-epoch day | |
103 | * @param day the 1970-epoch day (integral value) | |
104 | * @return the day of week | |
105 | */ | |
106 | public static int dayOfWeek(long day) { | |
107 | long[] remainder = new long[1]; | |
108 | floorDivide(day + Calendar.THURSDAY, 7, remainder); | |
109 | int dayOfWeek = (int)remainder[0]; | |
110 | dayOfWeek = (dayOfWeek == 0) ? 7 : dayOfWeek; | |
111 | return dayOfWeek; | |
112 | } | |
113 | ||
114 | public static int[] dayToFields(long day, int[] fields) { | |
115 | if (fields == null || fields.length < 5) { | |
116 | fields = new int[5]; | |
117 | } | |
118 | // Convert from 1970 CE epoch to 1 CE epoch (Gregorian calendar) | |
119 | day += JULIAN_1970_CE - JULIAN_1_CE; | |
120 | ||
121 | long[] rem = new long[1]; | |
122 | long n400 = floorDivide(day, 146097, rem); | |
123 | long n100 = floorDivide(rem[0], 36524, rem); | |
124 | long n4 = floorDivide(rem[0], 1461, rem); | |
125 | long n1 = floorDivide(rem[0], 365, rem); | |
126 | ||
127 | int year = (int)(400 * n400 + 100 * n100 + 4 * n4 + n1); | |
128 | int dayOfYear = (int)rem[0]; | |
129 | if (n100 == 4 || n1 == 4) { | |
130 | dayOfYear = 365; // Dec 31 at end of 4- or 400-yr cycle | |
131 | } | |
132 | else { | |
133 | ++year; | |
134 | } | |
135 | ||
136 | boolean isLeap = isLeapYear(year); | |
137 | int correction = 0; | |
138 | int march1 = isLeap ? 60 : 59; // zero-based DOY for March 1 | |
139 | if (dayOfYear >= march1) { | |
140 | correction = isLeap ? 1 : 2; | |
141 | } | |
142 | int month = (12 * (dayOfYear + correction) + 6) / 367; // zero-based month | |
143 | int dayOfMonth = dayOfYear - DAYS_BEFORE[isLeap ? month + 12 : month] + 1; // one-based DOM | |
144 | int dayOfWeek = (int)((day + 2) % 7); // day 0 is Monday(2) | |
145 | if (dayOfWeek < 1 /* Sunday */) { | |
146 | dayOfWeek += 7; | |
147 | } | |
148 | dayOfYear++; // 1-based day of year | |
149 | ||
150 | fields[0] = year; | |
151 | fields[1] = month; | |
152 | fields[2] = dayOfMonth; | |
153 | fields[3] = dayOfWeek; | |
154 | fields[4] = dayOfYear; | |
155 | ||
156 | return fields; | |
157 | } | |
158 | ||
159 | /* | |
160 | * Convert long time to date/time fields | |
161 | * | |
162 | * result[0] : year | |
163 | * result[1] : month | |
164 | * result[2] : dayOfMonth | |
165 | * result[3] : dayOfWeek | |
166 | * result[4] : dayOfYear | |
167 | * result[5] : millisecond in day | |
168 | */ | |
169 | public static int[] timeToFields(long time, int[] fields) { | |
170 | if (fields == null || fields.length < 6) { | |
171 | fields = new int[6]; | |
172 | } | |
173 | long[] remainder = new long[1]; | |
174 | long day = floorDivide(time, 24*60*60*1000 /* milliseconds per day */, remainder); | |
175 | dayToFields(day, fields); | |
176 | fields[5] = (int)remainder[0]; | |
177 | return fields; | |
178 | } | |
179 | ||
180 | public static long floorDivide(long numerator, long denominator) { | |
181 | // We do this computation in order to handle | |
182 | // a numerator of Long.MIN_VALUE correctly | |
183 | return (numerator >= 0) ? | |
184 | numerator / denominator : | |
185 | ((numerator + 1) / denominator) - 1; | |
186 | } | |
187 | ||
188 | private static long floorDivide(long numerator, long denominator, long[] remainder) { | |
189 | if (numerator >= 0) { | |
190 | remainder[0] = numerator % denominator; | |
191 | return numerator / denominator; | |
192 | } | |
193 | long quotient = ((numerator + 1) / denominator) - 1; | |
194 | remainder[0] = numerator - (quotient * denominator); | |
195 | return quotient; | |
196 | } | |
197 | ||
198 | /* | |
199 | * Returns the ordinal number for the specified day of week in the month. | |
200 | * The valid return value is 1, 2, 3, 4 or -1. | |
201 | */ | |
202 | public static int getDayOfWeekInMonth(int year, int month, int dayOfMonth) { | |
203 | int weekInMonth = (dayOfMonth + 6)/7; | |
204 | if (weekInMonth == 4) { | |
205 | if (dayOfMonth + 7 > monthLength(year, month)) { | |
206 | weekInMonth = -1; | |
207 | } | |
208 | } else if (weekInMonth == 5) { | |
209 | weekInMonth = -1; | |
210 | } | |
211 | return weekInMonth; | |
212 | } | |
213 | } |
18 | 18 | import junit.framework.TestCase; |
19 | 19 | import com.android.org.bouncycastle.crypto.Digest; |
20 | 20 | import com.android.org.bouncycastle.crypto.ExtendedDigest; |
21 | import tests.util.SummaryStatistics; | |
21 | 22 | |
22 | 23 | /** |
23 | 24 | * Implements unit tests for our JNI wrapper around OpenSSL. We use the |
35 | 36 | * @param newDigest The new digest implementation, provided by OpenSSL |
36 | 37 | */ |
37 | 38 | public void doTestMessageDigest(Digest oldDigest, Digest newDigest) { |
39 | final int WARMUP = 10; | |
38 | 40 | final int ITERATIONS = 100; |
39 | 41 | |
40 | 42 | byte[] data = new byte[1024]; |
53 | 55 | data[i] = (byte)i; |
54 | 56 | } |
55 | 57 | |
56 | long oldTime = 0; | |
57 | long newTime = 0; | |
58 | SummaryStatistics oldTime = new SummaryStatistics(); | |
59 | SummaryStatistics newTime = new SummaryStatistics(); | |
58 | 60 | |
59 | for (int j = 0; j < ITERATIONS; j++) { | |
60 | long t0 = System.currentTimeMillis(); | |
61 | for (int j = 0; j < ITERATIONS + WARMUP; j++) { | |
62 | long t0 = System.nanoTime(); | |
61 | 63 | for (int i = 0; i < 4; i++) { |
62 | 64 | oldDigest.update(data, 0, data.length); |
63 | 65 | } |
64 | 66 | int oldLength = oldDigest.doFinal(oldHash, 0); |
65 | long t1 = System.currentTimeMillis(); | |
67 | long t1 = System.nanoTime(); | |
66 | 68 | |
67 | oldTime = oldTime + (t1 - t0); | |
69 | if (j >= WARMUP) { | |
70 | oldTime.add(t1 - t0); | |
71 | } | |
68 | 72 | |
69 | long t2 = System.currentTimeMillis(); | |
73 | long t2 = System.nanoTime(); | |
70 | 74 | for (int i = 0; i < 4; i++) { |
71 | 75 | newDigest.update(data, 0, data.length); |
72 | 76 | } |
73 | 77 | int newLength = newDigest.doFinal(newHash, 0); |
74 | long t3 = System.currentTimeMillis(); | |
78 | long t3 = System.nanoTime(); | |
75 | 79 | |
76 | newTime = newTime + (t3 - t2); | |
80 | if (j >= WARMUP) { | |
81 | newTime.add(t3 - t2); | |
82 | } | |
77 | 83 | |
78 | 84 | assertEquals("Hash sizes must be equal", oldLength, newLength); |
79 | 85 | |
82 | 88 | } |
83 | 89 | } |
84 | 90 | |
85 | System.out.println("Time for " + ITERATIONS + " x old hash processing: " + oldTime + " ms"); | |
86 | System.out.println("Time for " + ITERATIONS + " x new hash processing: " + newTime + " ms"); | |
91 | System.out.println("Time for " + ITERATIONS + " x old hash processing: " | |
92 | + oldTime.toString()); | |
93 | System.out.println("Time for " + ITERATIONS + " x new hash processing: " | |
94 | + newTime.toString()); | |
87 | 95 | |
88 | assertTrue("New hash should be faster", newTime < oldTime); | |
96 | assertTrue("New hash should be faster:\nold=" + oldTime.toString() + "\nnew=" | |
97 | + newTime.toString(), newTime.mean() < oldTime.mean()); | |
89 | 98 | } |
90 | 99 | |
91 | 100 | /** |
3202 | 3202 | } |
3203 | 3203 | } |
3204 | 3204 | |
3205 | public void test_DefaultGCMTagSizeAlgorithmParameterSpec() throws Exception { | |
3206 | final String AES = "AES"; | |
3207 | final String AES_GCM = "AES/GCM/NoPadding"; | |
3208 | byte[] input = new byte[16]; | |
3209 | byte[] key = new byte[16]; | |
3210 | Cipher cipher = Cipher.getInstance(AES_GCM, "BC"); | |
3211 | AlgorithmParameters param = AlgorithmParameters.getInstance("GCM"); | |
3212 | param.init(new byte[] { | |
3213 | (byte) 48, // DER encoding : tag_Sequence | |
3214 | (byte) 14, // DER encoding : total length | |
3215 | (byte) 4, // DER encoding : tag_OctetString | |
3216 | (byte) 12, // DER encoding : counter length | |
3217 | // Note that IV's size 12 bytes is recommended, but authentication tag size should be 16 | |
3218 | // bytes. | |
3219 | (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, | |
3220 | (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }); | |
3221 | cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, AES), param); | |
3222 | byte[] ciphertext = cipher.update(input); | |
3223 | byte[] tag = cipher.doFinal(); | |
3224 | assertEquals(16, tag.length); | |
3225 | } | |
3226 | ||
3205 | 3227 | public void testAES_ECB_PKCS5Padding_ShortBuffer_Failure() throws Exception { |
3206 | 3228 | for (String provider : AES_PROVIDERS) { |
3207 | 3229 | testAES_ECB_PKCS5Padding_ShortBuffer_Failure(provider); |
3514 | 3536 | cipher.init(Cipher.ENCRYPT_MODE, keyGen.generateKeyPair().getPublic()); |
3515 | 3537 | cipher.doFinal(new byte[] {1,2,3,4}); |
3516 | 3538 | } |
3539 | ||
3540 | /* | |
3541 | * Check that GCM encryption with old and new instances update correctly. | |
3542 | * http://b/26694388 | |
3543 | */ | |
3544 | public void test_AESGCMNoPadding_Reuse_Success() throws Exception { | |
3545 | SecretKeySpec key = new SecretKeySpec(new byte[16], "AES"); | |
3546 | GCMParameterSpec spec = new GCMParameterSpec(128, new byte[12]); | |
3547 | Cipher c1 = Cipher.getInstance("AES/GCM/NoPadding"); | |
3548 | Cipher c2 = Cipher.getInstance("AES/GCM/NoPadding"); | |
3549 | ||
3550 | // Pollute the c1 cipher with AAD | |
3551 | c1.init(Cipher.ENCRYPT_MODE, key, spec); | |
3552 | c1.updateAAD(new byte[] { | |
3553 | 0x01, 0x02, 0x03, 0x04, 0x05, | |
3554 | }); | |
3555 | ||
3556 | // Now init each again and make sure the outputs are the same | |
3557 | c1.init(Cipher.ENCRYPT_MODE, key, spec); | |
3558 | c2.init(Cipher.ENCRYPT_MODE, key, spec); | |
3559 | ||
3560 | byte[] aad = new byte[] { | |
3561 | 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, | |
3562 | }; | |
3563 | c1.updateAAD(aad); | |
3564 | c2.updateAAD(aad); | |
3565 | ||
3566 | assertEquals(Arrays.toString(c1.doFinal()), Arrays.toString(c2.doFinal())); | |
3567 | ||
3568 | // .doFinal should also reset the state, so check that as well. | |
3569 | byte[] aad2 = new byte[] { | |
3570 | 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, | |
3571 | }; | |
3572 | ||
3573 | Cipher c3 = Cipher.getInstance("AES/GCM/NoPadding"); | |
3574 | c3.init(Cipher.ENCRYPT_MODE, key, spec); | |
3575 | ||
3576 | c1.updateAAD(aad2); | |
3577 | c3.updateAAD(aad2); | |
3578 | assertEquals(Arrays.toString(c1.doFinal()), Arrays.toString(c3.doFinal())); | |
3579 | } | |
3517 | 3580 | } |
98 | 98 | assertTrue("s.server.getLastAccessedTime()=" + s.server.getLastAccessedTime() + " " + |
99 | 99 | "s.client.getLastAccessedTime()=" + s.client.getLastAccessedTime(), |
100 | 100 | Math.abs(s.server.getLastAccessedTime() |
101 | - s.client.getLastAccessedTime()) < 1 * 1000); | |
101 | - s.client.getLastAccessedTime()) <= 1 * 1000); | |
102 | 102 | assertTrue(s.server.getLastAccessedTime() >= |
103 | 103 | s.server.getCreationTime()); |
104 | 104 | assertTrue(s.client.getLastAccessedTime() >= |
0 | -----BEGIN CERTIFICATE----- | |
1 | MIIFATCCA+mg^wIBAgIBADANBgkqhkiG9w0BAQQFADB/MQswCQYDVQQGEwJkZTEg | |
2 | MB4GA1UEChMXSW5zZWN1cmVUZXN0Q2VydGlmaWNhdGUxJzAlBgNVBAMTHkZvciBU | |
3 | ZXN0cyBPbmx5IG5leHQgZ2VuZXJhdGlvbjElMCMGCSqGSIb3DQEJARYWaW5zZWN1 | |
4 | cmVAdGVzdC5pbnNlY3VyZTAeFw0wMjA2MjcxMjE2MzJaFw0xMjA2MjQxMjE2MzJa | |
5 | MH8xCzAJBgNVBAYTAmRlMSAwHgYDVQQKExdJbnNlY3VyZVRlc3RDZXJ0aWZpY2F0 | |
6 | ZTEnMCUGA1UEAxMeRm9yIFRlc3RzIE9ubHkgbmV4dCBnZW5lcmF0aW9uMSUwIwYJ | |
7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 | |
24 | c2+J6XZ5iV58uyz4IJVgdq+kyXjopMiJV/cHqDX5fPeLT35L3UNZy8TdhHW+tj7X | |
25 | sZelbK6kig9mzOBV2g0Pa86DwctHxL/eRDqX0+Mkvy9YAsBVhHDhVRWBpVMmQFMd | |
26 | NbEiGRB0FEKTM+ztlb0QyBrhrjHI9a+P2Q5iap7HuiUrD7BRQ8YWEOUWI8jEdRaI | |
27 | kC/K0U+WTB6e32XidjR7GCqFULLCE45of5JWJ/eV9gL5znhbEg== | |
28 | -----END CERTIFICATE----- | |
29 | ||
30 |
0 | crc.reset(); | |
1 | crc.update(1); | |
2 | //System.out.print("value of crc"+crc.getValue()); | |
0 | crc.reset(); | |
1 | crc.update(1); | |
2 | //System.out.print("value of crc"+crc.getValue()); | |
3 | 3 | ⏎ |
0 | /* | |
1 | * Copyright 2015 The Android Open Source Project | |
2 | * | |
3 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | * you may not use this file except in compliance with the License. | |
5 | * You may obtain a copy of the License at | |
6 | * | |
7 | * http://www.apache.org/licenses/LICENSE-2.0 | |
8 | * | |
9 | * Unless required by applicable law or agreed to in writing, software | |
10 | * distributed under the License is distributed on an "AS IS" BASIS, | |
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | * See the License for the specific language governing permissions and | |
13 | * limitations under the License. | |
14 | */ | |
15 | ||
16 | package tests.util; | |
17 | ||
18 | public class SummaryStatistics { | |
19 | /** The number of values seen. */ | |
20 | private int numValues; | |
21 | ||
22 | /** Sum of the values. */ | |
23 | private double sum; | |
24 | ||
25 | /** Sum of the squares of the values added. */ | |
26 | private double squaresSum; | |
27 | ||
28 | /** The previously added value. */ | |
29 | private double lastValue; | |
30 | ||
31 | public SummaryStatistics() { | |
32 | } | |
33 | ||
34 | private double square(double value) { | |
35 | return value * value; | |
36 | } | |
37 | ||
38 | /** Add a new value to the values seen. */ | |
39 | public void add(double value) { | |
40 | sum += value - lastValue; | |
41 | squaresSum += square(value) - square(lastValue); | |
42 | numValues++; | |
43 | lastValue = value; | |
44 | } | |
45 | ||
46 | /** Mean of the values seen. */ | |
47 | public double mean() { | |
48 | return sum / numValues; | |
49 | } | |
50 | ||
51 | /** Variance of the values seen. */ | |
52 | public double var() { | |
53 | return (squaresSum / numValues) - square(mean()); | |
54 | } | |
55 | ||
56 | /** Standard deviation of the values seen. */ | |
57 | public double stddev() { | |
58 | return Math.sqrt(var()); | |
59 | } | |
60 | ||
61 | /** Coefficient of variation of the values seen. */ | |
62 | public double coeffVar() { | |
63 | return stddev() / mean(); | |
64 | } | |
65 | ||
66 | public String toString() { | |
67 | StringBuilder sb = new StringBuilder("SummaryStatistics{"); | |
68 | sb.append("n="); | |
69 | sb.append(numValues); | |
70 | sb.append(",mean="); | |
71 | sb.append(mean()); | |
72 | sb.append(",var="); | |
73 | sb.append(var()); | |
74 | sb.append(",stddev="); | |
75 | sb.append(stddev()); | |
76 | sb.append(",coeffVar="); | |
77 | sb.append(coeffVar()); | |
78 | sb.append('}'); | |
79 | return sb.toString(); | |
80 | } | |
81 | } |