2
0

asymmetric.service.spec.js 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130
  1. /*
  2. * Copyright 2018 Scytl Secure Electronic Voting SA
  3. *
  4. * All rights reserved
  5. *
  6. * See our extended copyright notice in *file 'Copyright.txt' which is part of this source code package
  7. */
  8. describe('Asymmetric service...', function() {
  9. 'use strict';
  10. describe('should be able to ..', function() {
  11. var _plaintext = 'Ox2fUJq1gAbX';
  12. var _privateKeyPem =
  13. '-----BEGIN RSA PRIVATE KEY-----MIIEowIBAAKCAQEAglypZU45bnf2opnRI+Y51VqouBpvDT33xIB/OtbwKzwVpi+JrjBFtfk33tE9t/dSRs79CK94HRhCWcOiLa2qWPrjeZ9SBiEyScrhIvRZVBF41zBgwQNuRvJCsKmAqlZaFNJDZxEP4repmlBn1CfVFmfrXmOKqwP5F7l9ZtucveRzsfmF1yVPFkW8TMuB3YqMiyymyqHlS8ujCsu5I8tpgPbwuxdMOY94fNhSXrYkY8IuX1g1zdq/Z1jluOaR/UqK4UpnbuJaH/F0VgDNiWh6cTD0DFGEk0b70i5wU4Q3L/S6XZQRvSuADoCbhwBKuFL5pW5n865oLVb5S3wuVdWaGwIDAQABAoIBAC/tn34Wf3kE9BGeGc1oFLVDaqqdVVz5/oEpeR2J7q0GnzMFYUpAhzC7WvY52cYsUPyll1Q9Jx0TUTmteo/uvKWQQFfz4nVMeS+2PoXabolBDzuWlsv/1eiRo0FOYHa/3siu8YcQN9X0DpAkpbfTmT1uoZOHZ3EuucMmOFu7vGn38Grw8bSxpR0uvTtnb8ygC+aB51y38RMyhzQQanrM8FMeAfDAy6IB0Yo7b0c50Cxa6Ax4nqn9LXyGakr5WeAMkgTIOA/GId9SZD4e5eRpq+628pOeR4O9datFltgl6r1+A4ii2VrJsDqeatGtODlX6KRKqwFHoGIa2TjgSZLuorECgYEAxeSZDOOgFsI5mB7RkRzZaQ9znJ15sgdyZiAFZAOUah4hSGdAXNAnZTlrdacduXEu3EfkpuPToX7xZSv5FRYwfBwMwCLeytlGLPjQzWejZGbo4+KqgzWb9fECDYVtDPlJ/+yLih9nt67BHweJKxYydl18rVigdVyy22X86NijSykCgYEAqKPUrXZAo+TJvmTw4tgsibJgvXBYBhmsej8mGNQw+Nyp2gV28sgm61ifIeXKS8teq+MFwGA6cHQedbsCqhMHokdhESZmlbWxhSFLihQcewBxwvrBwbaxI23yXRzwMewznZFL032PpcbqrmwFmcSSEZ3nmbvTH6ShqLW+pzDNp6MCgYBQLzdgxJ7qedqSa/JohTMG4e7rh9d2rpPJE7J7ewPZF8pOpx+qO+Gqn2COdJ+Ts2vUcAETKn9nEaPIZc/wnmQY9dioxbhWo0FPGaaphBPtq9Ez/XUv4zoFppk5V1X/isdUPsmvttf00oeIBiqrXbwmv+yz5JRn2Z7TTXjz9Ev+OQKBgQCUuoCMRzl1EgcXIqEL/0kwW6BUEqufHa9u1Ri9Vw6lvL8T6DPipMEmWK9nzuid9gtVns/ovTVtDgv7GuabplLaPQePf4WDzY11c0rSyS/hDyBFrK+LL5uEOqhAlJAGB2HyOj1clWVF+GvrTpuV5LZKUS/79pmZU7G7QCaX/0Ow7wKBgC/kDH7cmWQnWvvJ5izrx/7PogQVPOLELeUIGLu/hjsSdDKiFCxCUZ948+9NuG+DnpXDWzw//r8mPBRRGGsqFws5Aipp7yjQ3kRDCCzGelPCVhHyfmKqA+8ewXPulKS3/wIyHIvaXmsuAtTfurHtpRyzjKmCBK1Y6WQ3trIXvo7s-----END RSA PRIVATE KEY-----';
  14. var _publicKeyPem =
  15. '-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAglypZU45bnf2opnRI+Y51VqouBpvDT33xIB/OtbwKzwVpi+JrjBFtfk33tE9t/dSRs79CK94HRhCWcOiLa2qWPrjeZ9SBiEyScrhIvRZVBF41zBgwQNuRvJCsKmAqlZaFNJDZxEP4repmlBn1CfVFmfrXmOKqwP5F7l9ZtucveRzsfmF1yVPFkW8TMuB3YqMiyymyqHlS8ujCsu5I8tpgPbwuxdMOY94fNhSXrYkY8IuX1g1zdq/Z1jluOaR/UqK4UpnbuJaH/F0VgDNiWh6cTD0DFGEk0b70i5wU4Q3L/S6XZQRvSuADoCbhwBKuFL5pW5n865oLVb5S3wuVdWaGwIDAQAB-----END PUBLIC KEY-----';
  16. it('return a key pair', function() {
  17. // Note: Key size here is set to value lower than minimum value
  18. // allowed by policy in order to keep test time reasonable.
  19. var keyBitLength = 1024;
  20. var f = function(box) {
  21. var encryptionKeyPair =
  22. box.asymmetric.service.getKeyPairForEncryption();
  23. expect(encryptionKeyPair).toBeDefined();
  24. };
  25. f.policies = {
  26. asymmetric: {
  27. keypair: {
  28. encryption: {
  29. algorithm: Config.asymmetric.keypair.encryption.algorithm.RSA,
  30. provider: Config.asymmetric.keypair.encryption.provider.FORGE,
  31. keyLength: keyBitLength,
  32. publicExponent:
  33. Config.asymmetric.keypair.encryption.publicExponent.F4
  34. },
  35. secureRandom: {
  36. provider: Config.asymmetric.keypair.secureRandom.provider.SCYTL
  37. }
  38. }
  39. }
  40. };
  41. cryptolib('asymmetric.service', f);
  42. });
  43. it('return a signature and verify it', function() {
  44. cryptolib('asymmetric.service', 'commons.utils', function(box) {
  45. var converters = new box.commons.utils.Converters();
  46. var dataB64;
  47. dataB64 = converters.base64Encode(_plaintext);
  48. var arrayDataBase64 = [dataB64];
  49. var signatureBase64 =
  50. box.asymmetric.service.sign(_privateKeyPem, arrayDataBase64);
  51. var verified = box.asymmetric.service.verifySignature(
  52. signatureBase64, _publicKeyPem, arrayDataBase64);
  53. expect(verified).toBeTruthy();
  54. });
  55. });
  56. it('encrypts and decrypts data', function() {
  57. cryptolib('asymmetric.service', 'commons.utils', function(box) {
  58. var converters = new box.commons.utils.Converters();
  59. var dataB64 = converters.base64Encode(_plaintext);
  60. var encryptedDataB64 =
  61. box.asymmetric.service.encrypt(_publicKeyPem, dataB64);
  62. var decryptedDataB64 =
  63. box.asymmetric.service.decrypt(_privateKeyPem, encryptedDataB64);
  64. expect(decryptedDataB64).toBe(dataB64);
  65. });
  66. });
  67. it('verifies a signed xml', function() {
  68. cryptolib('asymmetric.service', 'commons.utils', function(box) {
  69. var inStream =
  70. [
  71. '<?xml version="1.0" encoding="UTF-8"?>',
  72. '<EML xmlns="urn:oasis:names:tc:evs:schema:eml" xmlns:scytl="http://www.scytl.com/schema/eml5.0/other" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:xnl="urn:oasis:names:tc:ciq:xsdschema:xNL:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="410-Ballots" SchemaVersion="5.0" xsi:schemaLocation="urn:oasis:names:tc:evs:schema:eml 410-ballots-v5-0.xsd http://www.scytl.com/schema/eml5.0/other other.xsd">',
  73. ' <TransactionId>testTransactionId</TransactionId>',
  74. ' <MessageLanguage>en</MessageLanguage>',
  75. ' <Seal>',
  76. ' <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>XICOqyVby006j6ziAkGhRV4mjqy0xcLHlTrhj0YpBag=</DigestValue></Reference></SignedInfo><SignatureValue>dNqz4wgVx4Ofp11kxuW2YABryNZdPpxWZskI0hevRMJVNh0MzY2hJd23nKajF9m6QOk+nRJW3ez9',
  77. 'KO2bG6vgSvoHmyRdpsi1yuzMk6zWGY2lwwJ4JFXFq/9R/ii64Y1GCJlg2JJWx4JCDZxwV8lCCgnp',
  78. '3N44Izt09pyT8441dHw=</SignatureValue><KeyInfo><KeyValue><RSAKeyValue><Modulus>t+qknJd/Kdo09fvQrRThqh/3EyDQj8zT1ZT7uXmivni4Vaysf6zHv+oORIvAt9ntZE2ZCif9v6CC',
  79. 'W+hmRFkdgRoVpmD2TErjykzowx6Ffyf5BkVnVB89+g/ZqNyyvXiBe8SmpBrRLOMifnbacyrJcsrH',
  80. 'fwlCnuyGKXj1LfzDcR8=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue></KeyValue></KeyInfo></Signature></Seal>',
  81. ' <Ballots>',
  82. ' <EventIdentifier Id="402880002c599a48012c59b1de6c0019">',
  83. ' <EventAlias>ELECTION_EVENT_1</EventAlias>',
  84. ' </EventIdentifier>',
  85. ' <Ballot>',
  86. ' <Election>',
  87. ' <ElectionIdentifier Id="8080808032432a4b01324332702c0002">',
  88. ' <ElectionGroup Id="402880002c599a48012c59b0e4130001"/>',
  89. ' </ElectionIdentifier>',
  90. ' <Description>',
  91. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0008" Lang="en" TranslationId="8080808032432a4b01324332702d0009" Type="title">Default Message_3_1</Message>',
  92. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0008" Lang="es" TranslationId="8080808032432a4b01324332702d000a" Type="title">Mensaje por Defecto_3_1</Message>',
  93. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0008" Lang="ca" TranslationId="8080808032432a4b01324332702d000b" Type="title">Missatge per Defecte_3_1</Message>',
  94. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0008" Lang="fr" TranslationId="8080808032432a4b01324332702d000c" Type="title">Message par defaut_3_1</Message>',
  95. ' </Description>',
  96. ' <Messages>',
  97. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0003" Lang="en" TranslationId="8080808032432a4b01324332702c0004" Type="alternateReceiptMessage">Default Message</Message>',
  98. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0003" Lang="es" TranslationId="8080808032432a4b01324332702c0005" Type="alternateReceiptMessage">Mensaje por Defecto</Message>',
  99. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0003" Lang="ca" TranslationId="8080808032432a4b01324332702c0006" Type="alternateReceiptMessage">Missatge per Defecte</Message>',
  100. ' <Message Format="plainText" Id="8080808032432a4b01324332702c0003" Lang="fr" TranslationId="8080808032432a4b01324332702c0007" Type="alternateReceiptMessage">Message par defaut</Message>',
  101. ' </Messages>',
  102. ' </Election>',
  103. ' <BallotIdentifier Id="GLOBAL_DISTRICT"/>',
  104. ' <scytl:ShowReceipt>true</scytl:ShowReceipt>',
  105. ' <scytl:RedirectExitUrl/>',
  106. ' <scytl:RedirectHelpUrl/>',
  107. ' </Ballot>',
  108. ' </Ballots>',
  109. '</EML>'
  110. ].join('\n');
  111. var publicKeyPem = [
  112. '-----BEGIN CERTIFICATE-----',
  113. 'MIICcTCCAVmgAwIBAgIBATANBgkqhkiG9w0BAQQFADA+MQswCQYDVQQGEwJFUzEbMBkGA1UEChMS',
  114. 'U2N5dGwgVU5JVCBURVNUIENBMRIwEAYDVQQLEwlVTklUIFRFU1QwHhcNMDYwMzAyMTEwOTEyWhcN',
  115. 'MzAwNDA2MTEwOTEyWjA+MQswCQYDVQQGEwJFUzEbMBkGA1UEChMSU2N5dGwgVU5JVCBURVNUIENB',
  116. 'MRIwEAYDVQQLEwlVTklUIFRFU1QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALfqpJyXfyna',
  117. 'NPX70K0U4aof9xMg0I/M09WU+7l5or54uFWsrH+sx7/qDkSLwLfZ7WRNmQon/b+gglvoZkRZHYEa',
  118. 'FaZg9kxK48pM6MMehX8n+QZFZ1QfPfoP2ajcsr14gXvEpqQa0SzjIn522nMqyXLKx38JQp7shil4',
  119. '9S38w3EfAgMBAAEwDQYJKoZIhvcNAQEEBQADggEBAJrtSsuqdB3RvGZMriETpO0pqQsBhZ+JRYqs',
  120. '5dFIiC+bdJE+dUB6v8fpv1exSQ0+i+e1oTs2I9Wd4eIQ4rlZCG9K6EYBKP9Z59OBDTf6luaisoul',
  121. '6gnKW7+kUfQQkBfJJw/4RA7FbaAmYNGEEfXTwDMU+ZoqIO/PV+JsfOtFUdPcwv1hPQHTE+KR1DtR',
  122. 'AC+A4Ak+fOoaRnyTprvbT4inaPdn6D9fBrIpO6hQSAtM5K9+/VaskMSFqw03DkADRyxHacdz9JLp',
  123. '5ChDbRrXCDdT/a832acPDViS3nG/GhuSTK8mlrXeHjpG6vaSbKiXNXwrwz80k/XoNh3k5jlfrzUM',
  124. 'CQ4=', '-----END CERTIFICATE-----'
  125. ].join('\n');
  126. var signatureParentNode = 'EML/Seal/Signature';
  127. // get the public key
  128. var abCert = box.forge.pki.certificateFromPem(publicKeyPem, true);
  129. var publicKey = abCert.publicKey;
  130. // test it
  131. var verified = box.asymmetric.service.verifyXmlSignature(
  132. publicKey, inStream, signatureParentNode);
  133. expect(verified).toBeTruthy();
  134. });
  135. });
  136. it('verifies a second signed xml',
  137. function() {
  138. cryptolib(
  139. 'asymmetric.service', 'commons.utils', function(box) {
  140. var inStream = [
  141. '<?xml version="1.0" encoding="UTF-8"?>',
  142. '<EML xmlns="urn:oasis:names:tc:evs:schema:eml" xmlns:al="urn:oasis:names:tc:ciq:xal:4" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:nl="urn:oasis:names:tc:ciq:xnl:4" xmlns:ts="urn:oasis:names:tc:evs:schema:eml:ts" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="330" SchemaVersion="7.0" xsi:schemaLocation="urn:oasis:names:tc:evs:schema:eml ../../330-electionlist-v7-0.xsd">',
  143. ' <EMLHeader>',
  144. ' <TransactionId>330</TransactionId>',
  145. ' <SequenceNumber>1</SequenceNumber>',
  146. ' <NumberInSequence>1</NumberInSequence>',
  147. ' <SequencedElementName>Set20131125</SequencedElementName>',
  148. ' <OfficialStatusDetail>',
  149. ' <OfficialStatus/>',
  150. ' <StatusDate>2013-11-25</StatusDate>',
  151. ' </OfficialStatusDetail>',
  152. ' <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>BbEhPY/Q2JegRUtLYUR/9I0ColZlnKVG4kZ9U2fjh6k=</DigestValue></Reference></SignedInfo><SignatureValue>vXdMpLJB1ECStXim5aO0bpOq/Em6OA/zH/uAPI4nWTUjoRPeMHO/YkeJl4jfL/ImQtisTVG6mBpa',
  153. 'LejeM6PKBv9G5zTnymZn+1mn2iRpKkW5MB+cbifPfh6ut7RHWfA4N3ZAxYz+Zh5WEMDZLPapuLTM',
  154. 'qbczC9THziQRgdvEcn0=</SignatureValue></Signature></EMLHeader>',
  155. ' <ElectionList>',
  156. ' <Qualifier>',
  157. ' <VoterGroup>MILITARY_NOTOVERSEAS</VoterGroup>',
  158. ' </Qualifier>',
  159. ' <PollingDistrict>',
  160. ' <Name>Sebastian</Name>',
  161. ' <Association Id="AR-66"/>',
  162. ' </PollingDistrict>',
  163. ' <EventIdentifier IdNumber="GE2013"/>',
  164. ' <EventDate>',
  165. ' <Start>2013-12-24</Start>',
  166. ' <End>2013-12-24</End>',
  167. ' </EventDate>',
  168. ' <VoterDetails>',
  169. ' <RequestedAction>add</RequestedAction>',
  170. ' <VoterRegistration>',
  171. ' <Voter>',
  172. ' <VoterIdentification Id="3545231">',
  173. ' <VoterName>',
  174. ' <nl:PersonNameDetail>',
  175. ' <nl:NamePrefixText/>',
  176. ' <nl:GivenName>Steven</nl:GivenName>',
  177. ' <nl:MiddleName/>',
  178. ' <nl:FamilyName>Perez</nl:FamilyName>',
  179. ' <nl:NameSuffixText/>',
  180. ' </nl:PersonNameDetail>',
  181. ' </VoterName>',
  182. ' <ElectoralAddress>',
  183. ' <al:FreeTextAddress>',
  184. ' <al:AddressLine seqn="1" type="RegisteredAddress">1434 N 34th St </al:AddressLine>',
  185. ' <al:AddressLine seqn="2" type="RegisteredAddress">Fort Smith, AR</al:AddressLine>',
  186. ' <al:AddressLine type="RegisteredAddressPostalCode">72904</al:AddressLine>',
  187. ' <al:AddressLine seqn="1" type="MailToAddress">123 man line 1 address </al:AddressLine>',
  188. ' <al:AddressLine seqn="2" type="MailoAddress">somewheretown, OR </al:AddressLine>',
  189. ' <al:AddressLine type="MailToAddressPostalCode">11236-5456</al:AddressLine>',
  190. ' <al:AddressLine type="email">ballotsafe-test+ARvoter11@scytl.com</al:AddressLine>',
  191. ' </al:FreeTextAddress>',
  192. ' </ElectoralAddress>',
  193. ' <VToken VTokenId="GE20133545231">',
  194. ' <Component/>',
  195. ' <BallotIdentifier IdNumber="1-A.01"/>',
  196. ' </VToken>',
  197. ' <VoterId type="driverslicense"/>',
  198. ' </VoterIdentification>',
  199. ' <VoterInformation>',
  200. ' <DateOfBirth>1983-03-16</DateOfBirth>',
  201. ' <PreferredLanguage>en-US</PreferredLanguage>',
  202. ' <Affiliation>Republican</Affiliation>',
  203. ' </VoterInformation>',
  204. ' <BallotFormIdentifier Permitted="yes" Received="no" Voted="no">1-A.01</BallotFormIdentifier>',
  205. ' <Messages>',
  206. ' <Message/>',
  207. ' </Messages>',
  208. ' </Voter>',
  209. ' </VoterRegistration>',
  210. ' <Election>',
  211. ' <PollingDistrict>',
  212. ' <Name>Sebastian</Name>',
  213. ' <Association Id="AR-66"/>',
  214. ' </PollingDistrict>',
  215. ' <PollingPlace Channel="polling" IdNumber="1-A.01">',
  216. ' <OtherLocation>1-A.1</OtherLocation>',
  217. ' </PollingPlace>',
  218. ' </Election>',
  219. ' </VoterDetails>',
  220. ' <VoterDetails>',
  221. ' <RequestedAction>add</RequestedAction>',
  222. ' <VoterRegistration>',
  223. ' <Voter>',
  224. ' <VoterIdentification Id="502445">',
  225. ' <VoterName>',
  226. ' <nl:PersonNameDetail>',
  227. ' <nl:NamePrefixText/>',
  228. ' <nl:GivenName>Mingkhone</nl:GivenName>',
  229. ' <nl:MiddleName/>',
  230. ' <nl:FamilyName>Ratsamy</nl:FamilyName>',
  231. ' <nl:NameSuffixText/>',
  232. ' </nl:PersonNameDetail>',
  233. ' </VoterName>',
  234. ' <ElectoralAddress>',
  235. ' <al:FreeTextAddress>',
  236. ' <al:AddressLine seqn="1" type="RegisteredAddress">1443 N 44th St </al:AddressLine>',
  237. ' <al:AddressLine seqn="2" type="RegisteredAddress">Fort Smith, AR</al:AddressLine>',
  238. ' <al:AddressLine type="RegisteredAddressPostalCode">72904</al:AddressLine>',
  239. ' <al:AddressLine seqn="1" type="MailToAddress">Line 1 address length in all address fields for </al:AddressLine>',
  240. ' <al:AddressLine seqn="2" type="MailoAddress">somewheretown, CA </al:AddressLine>',
  241. ' <al:AddressLine type="MailToAddressPostalCode">11123-4567</al:AddressLine>',
  242. ' <al:AddressLine type="email">ballotsafe-test+ARvoter12@scytl.com</al:AddressLine>',
  243. ' </al:FreeTextAddress>',
  244. ' </ElectoralAddress>',
  245. ' <VToken VTokenId="GE2013502445">',
  246. ' <Component/>',
  247. ' <BallotIdentifier IdNumber="1-A.01"/>',
  248. ' </VToken>',
  249. ' <VoterId type="driverslicense"/>',
  250. ' </VoterIdentification>',
  251. ' <VoterInformation>',
  252. ' <DateOfBirth>1987-03-23</DateOfBirth>',
  253. ' <PreferredLanguage>en-US</PreferredLanguage>',
  254. ' <Affiliation>Democratic</Affiliation>',
  255. ' </VoterInformation>',
  256. ' <BallotFormIdentifier Permitted="yes" Received="no" Voted="no">1-A.01</BallotFormIdentifier>',
  257. ' <Messages>',
  258. ' <Message/>',
  259. ' </Messages>',
  260. ' </Voter>',
  261. ' </VoterRegistration>',
  262. ' <Election>',
  263. ' <PollingDistrict>',
  264. ' <Name>Sebastian</Name>',
  265. ' <Association Id="AR-66"/>',
  266. ' </PollingDistrict>',
  267. ' <PollingPlace Channel="polling" IdNumber="1-A.01">',
  268. ' <OtherLocation>1-A.1</OtherLocation>',
  269. ' </PollingPlace>',
  270. ' </Election>',
  271. ' </VoterDetails>',
  272. ' <VoterDetails>',
  273. ' <RequestedAction>add</RequestedAction>',
  274. ' <VoterRegistration>',
  275. ' <Voter>',
  276. ' <VoterIdentification Id="501990">',
  277. ' <VoterName>',
  278. ' <nl:PersonNameDetail>',
  279. ' <nl:NamePrefixText/>',
  280. ' <nl:GivenName>James</nl:GivenName>',
  281. ' <nl:MiddleName>Maxwell</nl:MiddleName>',
  282. ' <nl:FamilyName>Smith</nl:FamilyName>',
  283. ' <nl:NameSuffixText>Sr </nl:NameSuffixText>',
  284. ' </nl:PersonNameDetail>',
  285. ' </VoterName>',
  286. ' <ElectoralAddress>',
  287. ' <al:FreeTextAddress>',
  288. ' <al:AddressLine seqn="1" type="RegisteredAddress">1534 N 49th St </al:AddressLine>',
  289. ' <al:AddressLine seqn="2" type="RegisteredAddress">Fort Smith, AR</al:AddressLine>',
  290. ' <al:AddressLine type="RegisteredAddressPostalCode">72904</al:AddressLine>',
  291. ' <al:AddressLine seqn="1" type="MailToAddress">',
  292. 'test address length in all address fields for scyt </al:AddressLine>',
  293. ' <al:AddressLine seqn="2" type="MailoAddress">somewheretownusa, mt </al:AddressLine>',
  294. ' <al:AddressLine type="MailToAddressPostalCode">21453-3335</al:AddressLine>',
  295. ' <al:AddressLine type="email">ballotsafe-test+ARvoter13@scytl.com</al:AddressLine>',
  296. ' </al:FreeTextAddress>',
  297. ' </ElectoralAddress>',
  298. ' <VToken VTokenId="GE2013501990">',
  299. ' <Component/>',
  300. ' <BallotIdentifier IdNumber="1-A.01"/>',
  301. ' </VToken>',
  302. ' <VoterId type="driverslicense"/>',
  303. ' </VoterIdentification>',
  304. ' <VoterInformation>',
  305. ' <DateOfBirth>1956-02-29</DateOfBirth>',
  306. ' <PreferredLanguage>en-US</PreferredLanguage>',
  307. ' <Affiliation>Optional</Affiliation>',
  308. ' </VoterInformation>',
  309. ' <BallotFormIdentifier Permitted="yes" Received="no" Voted="no">1-A.01</BallotFormIdentifier>',
  310. ' <Messages>',
  311. ' <Message/>',
  312. ' </Messages>',
  313. ' </Voter>',
  314. ' </VoterRegistration>',
  315. ' <Election>',
  316. ' <PollingDistrict>',
  317. ' <Name>Sebastian</Name>',
  318. ' <Association Id="AR-66"/>',
  319. ' </PollingDistrict>',
  320. ' <PollingPlace Channel="polling" IdNumber="1-A.01">',
  321. ' <OtherLocation>1-A.1</OtherLocation>',
  322. ' </PollingPlace>',
  323. ' </Election>',
  324. ' </VoterDetails>',
  325. ' <VoterDetails>',
  326. ' <RequestedAction>add</RequestedAction>',
  327. ' <VoterRegistration>',
  328. ' <Voter>',
  329. ' <VoterIdentification Id="3558060">',
  330. ' <VoterName>',
  331. ' <nl:PersonNameDetail>',
  332. ' <nl:NamePrefixText/>',
  333. ' <nl:GivenName>Jordan</nl:GivenName>',
  334. ' <nl:MiddleName>Elizabeth</nl:MiddleName>',
  335. ' <nl:FamilyName>Stephenson</nl:FamilyName>',
  336. ' <nl:NameSuffixText/>',
  337. ' </nl:PersonNameDetail>',
  338. ' </VoterName>',
  339. ' <ElectoralAddress>',
  340. ' <al:FreeTextAddress>',
  341. ' <al:AddressLine seqn="1" type="RegisteredAddress">700 N Albert Pike, Apt 1204 </al:AddressLine>',
  342. ' <al:AddressLine seqn="2" type="RegisteredAddress">Fort Smith, AR</al:AddressLine>',
  343. ' <al:AddressLine type="RegisteredAddressPostalCode">72903</al:AddressLine>',
  344. ' <al:AddressLine seqn="1" type="MailToAddress">test address length in all address fields for scyt Line 2 address length in all address fields for Line 3 address length in all address fields for Line 4 address length in all address fields for </al:AddressLine>',
  345. ' <al:AddressLine seqn="2" type="MailoAddress">somewheretown, cn </al:AddressLine>',
  346. ' <al:AddressLine type="MailToAddressPostalCode">11123-4555</al:AddressLine>',
  347. ' <al:AddressLine type="email">ballotsafe-test+ARvoter14@scytl.com</al:AddressLine>',
  348. ' </al:FreeTextAddress>',
  349. ' </ElectoralAddress>',
  350. ' <VToken VTokenId="GE20133558060">',
  351. ' <Component/>',
  352. ' <BallotIdentifier IdNumber="1-A.01"/>',
  353. ' </VToken>',
  354. ' <VoterId type="driverslicense"/>',
  355. ' </VoterIdentification>',
  356. ' <VoterInformation>',
  357. ' <DateOfBirth>1992-08-31</DateOfBirth>',
  358. ' <PreferredLanguage>en-US</PreferredLanguage>',
  359. ' <Affiliation>Optional</Affiliation>',
  360. ' </VoterInformation>',
  361. ' <BallotFormIdentifier Permitted="yes" Received="no" Voted="no">1-A.01</BallotFormIdentifier>',
  362. ' <Messages>',
  363. ' <Message/>',
  364. ' </Messages>',
  365. ' </Voter>',
  366. ' </VoterRegistration>',
  367. ' <Election>',
  368. ' <PollingDistrict>',
  369. ' <Name>Sebastian</Name>',
  370. ' <Association Id="AR-66"/>',
  371. ' </PollingDistrict>',
  372. ' <PollingPlace Channel="polling" IdNumber="1-A.01">',
  373. ' <OtherLocation>1-A.1</OtherLocation>',
  374. ' </PollingPlace>',
  375. ' </Election>',
  376. ' </VoterDetails>',
  377. ' <VoterDetails>',
  378. ' <RequestedAction>add</RequestedAction>',
  379. ' <VoterRegistration>',
  380. ' <Voter>',
  381. ' <VoterIdentification Id="893572">',
  382. ' <VoterName>',
  383. ' <nl:PersonNameDetail>',
  384. ' <nl:NamePrefixText/>',
  385. ' <nl:GivenName>Donna</nl:GivenName>',
  386. ' <nl:MiddleName>S</nl:MiddleName>',
  387. ' <nl:FamilyName>Van Evera</nl:FamilyName>',
  388. ' <nl:NameSuffixText/>',
  389. ' </nl:PersonNameDetail>',
  390. ' </VoterName>',
  391. ' <ElectoralAddress>',
  392. ' <al:FreeTextAddress>',
  393. ' <al:AddressLine seqn="1" type="RegisteredAddress">4420 Kinkead </al:AddressLine>',
  394. ' <al:AddressLine seqn="2" type="RegisteredAddress">Fort Smith, AR</al:AddressLine>',
  395. ' <al:AddressLine type="RegisteredAddressPostalCode">72903</al:AddressLine>',
  396. ' <al:AddressLine seqn="1" type="MailToAddress">test address length in all address fields for scyt Line 3 address length in all address fields for sc </al:AddressLine>',
  397. ' <al:AddressLine seqn="2" type="MailoAddress">anywheretown, vt </al:AddressLine>',
  398. ' <al:AddressLine type="MailToAddressPostalCode">12546-3333</al:AddressLine>',
  399. ' <al:AddressLine type="email">ballotsafe-test+ARvoter15@scytl.com</al:AddressLine>',
  400. ' </al:FreeTextAddress>',
  401. ' </ElectoralAddress>',
  402. ' <VToken VTokenId="GE2013893572">',
  403. ' <Component/>',
  404. ' <BallotIdentifier IdNumber="1-A.01"/>',
  405. ' </VToken>',
  406. ' <VoterId type="driverslicense"/>',
  407. ' </VoterIdentification>',
  408. ' <VoterInformation>',
  409. ' <DateOfBirth>1952-12-21</DateOfBirth>',
  410. ' <PreferredLanguage>en-US</PreferredLanguage>',
  411. ' <Affiliation>Optional</Affiliation>',
  412. ' </VoterInformation>',
  413. ' <BallotFormIdentifier Permitted="yes" Received="no" Voted="no">1-A.01</BallotFormIdentifier>',
  414. ' <Messages>',
  415. ' <Message/>',
  416. ' </Messages>',
  417. ' </Voter>',
  418. ' </VoterRegistration>',
  419. ' <Election>',
  420. ' <PollingDistrict>',
  421. ' <Name>Sebastian</Name>',
  422. ' <Association Id="AR-66"/>',
  423. ' </PollingDistrict>',
  424. ' <PollingPlace Channel="polling" IdNumber="1-A.01">',
  425. ' <OtherLocation>1-A.1</OtherLocation>',
  426. ' </PollingPlace>',
  427. ' </Election>',
  428. ' </VoterDetails>',
  429. ' </ElectionList>',
  430. '</EML>'
  431. ].join('\n');
  432. var publicKeyPem = [
  433. '-----BEGIN CERTIFICATE-----',
  434. 'MIICfjCCAeegAwIBAgIJAJQ9YClOoquEMA0GCSqGSIb3DQEBBQUAMFgxCzAJBgNV',
  435. 'BAYTAlVTMQwwCgYDVQQIDANXQVMxDDAKBgNVBAcMA1dBUzEMMAoGA1UECgwDU09F',
  436. 'MQ8wDQYDVQQLDAZTT0VfUUExDjAMBgNVBAMMBVRlc3QyMB4XDTE0MTExMjE0MDA0',
  437. 'MVoXDTE1MTExMjE0MDA0MVowWDELMAkGA1UEBhMCVVMxDDAKBgNVBAgMA1dBUzEM',
  438. 'MAoGA1UEBwwDV0FTMQwwCgYDVQQKDANTT0UxDzANBgNVBAsMBlNPRV9RQTEOMAwG',
  439. 'A1UEAwwFVGVzdDIwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL/9d+ZKlFSn',
  440. 'j7hJTGTOStQv+4TCc4cdKjGeCTOqj8J6ShxBfB03x/PVZgv4bWdZjjz7TT+adLq9',
  441. 'FhTn064mZJW6PL+6Dv1EENMDp/RavvFbQG0Egkqg6Gxo7ttp2dGzt2AXN9veH2UB',
  442. 'alkIFG85dTQ6nb+W3nyJCs1k80eSGFfPAgMBAAGjUDBOMB0GA1UdDgQWBBQBXb/9',
  443. 'TEOHKOqgrIG3wXsspccXMjAfBgNVHSMEGDAWgBQBXb/9TEOHKOqgrIG3wXsspccX',
  444. 'MjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAA4GBAJiUTSthh3SAJIDxhCoe',
  445. '20xFwdjXEEU8MMODEh3ibHzFcf9JXqkTAhZ8ExtFsMzpDEi7YBNB+FkBpFEtkzRA',
  446. 'BLK7JmLkje7lg3aXz6PRRd/LegrRmT1klFUHmqKEBJt5185UE2B8mDXWJEdptLsR',
  447. '8AEw5IwDqHQWPA6gk8XyQ5s6', '-----END CERTIFICATE-----'
  448. ].join('\n');
  449. var signatureParentNode = 'EML/EMLHeader/Signature';
  450. // get the public key
  451. var abCert =
  452. box.forge.pki.certificateFromPem(publicKeyPem, true);
  453. var publicKey = abCert.publicKey;
  454. // test it
  455. var verified = box.asymmetric.service.verifyXmlSignature(
  456. publicKey, inStream, signatureParentNode);
  457. expect(verified).toBeTruthy();
  458. });
  459. });
  460. it('verifies a third signed xml', function() {
  461. /*jshint smarttabs:true */
  462. cryptolib('asymmetric.service', 'commons.utils', function(box) {
  463. var inStream = [
  464. '<?xml version="1.0" encoding="UTF-8"?>',
  465. '<xml xmlns="urn:oasis:names:tc:evs:schema:eml" xmlns:nswec="urn:nswec:events:emlExtension" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:xnl="urn:oasis:names:tc:ciq:xsdschema:xNL:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:evs:schema:eml http://docs.oasis-open.org/election/eml/v5.0/os/EML-Schemas-v5.0/110-electionevent-v5-0.xsd urn:nswec:events:emlExtension http://www.elections.nsw.gov.au/standards/XML/emlcore-v5-0-NSWEC.xsd">',
  466. ' <ElectionEvent graceperiod="1800"> <!-- grace period is the time in seconds allowed after loginEnd to cast a vote, this period applies to all Voting Modes -->',
  467. ' <EventIdentifier Id="SG1409-110">',
  468. ' <EventQualifier Id="SG1409">NSW State General Election 2015</EventQualifier>',
  469. ' </EventIdentifier>',
  470. ' <Election>',
  471. ' <iVoteModes>',
  472. ' <iVoteMode name="Test">',
  473. ' <Venues>',
  474. ' <Venue IssuingVenue="NSW" ballotboxid="SG1409-BB-000" id="00" venueid="SG1409-VN-000"/>',
  475. ' </Venues>',
  476. ' <Periods type="votingmode">',
  477. ' <Period loginEnd="2015-03-28T18:00:00+10:00" loginStart="2014-03-16T08:00:00+10:00" name="test"/>',
  478. ' <Closing manual="yes"/>',
  479. ' </Periods>',
  480. ' <VotingClients>',
  481. ' <VotingClient type="web"/>',
  482. ' <VotingClient type="phone"/>',
  483. ' </VotingClients>',
  484. ' </iVoteMode>',
  485. ' <iVoteMode name="Attendance">',
  486. ' <Periods type="venues"> <!-- As well as defining iVote login times, these datetimes would be used by CVS to distinguish between prepoll and Election Day votes -->',
  487. ' <Period loginEnd="2015-03-27T20:00:00+10:00" loginStart="2014-03-16T08:00:00+10:00" name="prepoll"/>',
  488. ' <Period loginEnd="2015-03-28T20:00:00+10:00" loginStart="2014-03-28T08:00:00+10:00" name="electionday"/>',
  489. ' <Closing manual="yes"/>',
  490. ' </Periods>',
  491. ' <Venues>',
  492. ' <Venue IssuingDistrict="Sydney" IssuingVenue="SydneyTownHall" ballotboxid="SG1409-BB-001" id="01" venueid="SG1409-VN-001"/>',
  493. ' <Venue IssuingDistrict="Bega" IssuingVenue="CandeloTownHall" ballotboxid="SG1409-BB-002" id="02" venueid="SG1409-VN-002"/>',
  494. ' </Venues>',
  495. ' <VotingClients>',
  496. ' <VotingClient type="web"/>',
  497. ' </VotingClients>',
  498. ' </iVoteMode>',
  499. ' <iVoteMode name="Remote Venue">',
  500. ' <Periods type="votingmode">',
  501. ' <Period loginEnd="2015-03-28T18:00:00+10:00" loginStart="2014-03-16T08:00:00+10:00" name="remotevenue"/>',
  502. ' <Closing manual="yes"/>',
  503. ' </Periods>',
  504. ' <Venues>',
  505. ' <Venue IssuingVenue="NSW" ballotboxid="SG1409-BB-003" id="03" venueid="SG1409-VN-003"/>',
  506. ' </Venues>',
  507. ' <VotingClients>',
  508. ' <VotingClient type="web"/>',
  509. ' </VotingClients>',
  510. ' </iVoteMode>',
  511. ' <iVoteMode name="Remote">',
  512. ' <Venues>',
  513. ' <Venue IssuingVenue="NSW" ballotboxid="SG1409-BB-003" id="04" venueid="SG1409-VN-003"/>',
  514. ' </Venues>',
  515. ' <Periods type="votingmode">',
  516. ' <Period loginEnd="2015-03-28T18:00:00+10:00" loginStart="2014-03-16T08:00:00+10:00" name="remote"/>',
  517. ' <Closing manual="no"/>',
  518. ' </Periods>',
  519. ' <VotingClients>',
  520. ' <VotingClient type="web"/>',
  521. ' <VotingClient type="phone"/>',
  522. ' </VotingClients>',
  523. ' </iVoteMode>',
  524. ' ',
  525. ' </iVoteModes>',
  526. ' <contest>',
  527. ' <Area Id="100" Type="LA District">Albury</Area>',
  528. ' </contest>',
  529. ' <contest>',
  530. ' <Area Id="200" Type="LA District">Auburn</Area>',
  531. ' </contest>',
  532. ' <contest>',
  533. ' <Area Id="300" Type="LA District">Ballina</Area>',
  534. ' </contest>',
  535. ' <contest>',
  536. ' <Area Id="400" Type="LA District">Balmain</Area>',
  537. ' </contest>',
  538. ' <contest>',
  539. ' <Area Id="500" Type="LA District">Bankstown</Area>',
  540. ' </contest>',
  541. ' <contest>',
  542. ' <Area Id="600" Type="LA District">Barwon</Area>',
  543. ' </contest>',
  544. ' <contest>',
  545. ' <Area Id="700" Type="LA District">Bathurst</Area>',
  546. ' </contest>',
  547. ' <contest>',
  548. ' <Area Id="800" Type="LA District">Baulkham Hills</Area>',
  549. ' </contest>',
  550. ' <contest>',
  551. ' <Area Id="900" Type="LA District">Bega</Area>',
  552. ' </contest>',
  553. ' <contest>',
  554. ' <Area Id="1000" Type="LA District">Blacktown</Area>',
  555. ' </contest>',
  556. ' <contest>',
  557. ' <Area Id="1100" Type="LA District">Blue Mountains</Area>',
  558. ' </contest>',
  559. ' <contest>',
  560. ' <Area Id="1200" Type="LA District">Burrinjuck</Area>',
  561. ' </contest>',
  562. ' <contest>',
  563. ' <Area Id="1300" Type="LA District">Cabramatta</Area>',
  564. ' </contest>',
  565. ' <contest>',
  566. ' <Area Id="1400" Type="LA District">Camden</Area>',
  567. ' </contest>',
  568. ' <contest>',
  569. ' <Area Id="1500" Type="LA District">Campbelltown</Area>',
  570. ' </contest>',
  571. ' <contest>',
  572. ' <Area Id="1600" Type="LA District">Canterbury</Area>',
  573. ' </contest>',
  574. ' <contest>',
  575. ' <Area Id="1700" Type="LA District">Castle Hill</Area>',
  576. ' </contest>',
  577. ' <contest>',
  578. ' <Area Id="1800" Type="LA District">Cessnock</Area>',
  579. ' </contest>',
  580. ' <contest>',
  581. ' <Area Id="1900" Type="LA District">Charlestown</Area>',
  582. ' </contest>',
  583. ' <contest>',
  584. ' <Area Id="2000" Type="LA District">Clarence</Area>',
  585. ' </contest>',
  586. ' <contest>',
  587. ' <Area Id="2100" Type="LA District">Coffs Harbour</Area>',
  588. ' </contest>',
  589. ' <contest>',
  590. ' <Area Id="2200" Type="LA District">Coogee</Area>',
  591. ' </contest>',
  592. ' <contest>',
  593. ' <Area Id="2300" Type="LA District">Cronulla</Area>',
  594. ' </contest>',
  595. ' <contest>',
  596. ' <Area Id="2400" Type="LA District">Davidson</Area>',
  597. ' </contest>',
  598. ' <contest>',
  599. ' <Area Id="2500" Type="LA District">Drummoyne</Area>',
  600. ' </contest>',
  601. ' <contest>',
  602. ' <Area Id="2600" Type="LA District">Dubbo</Area>',
  603. ' </contest>',
  604. ' <contest>',
  605. ' <Area Id="2700" Type="LA District">East Hills</Area>',
  606. ' </contest>',
  607. ' <contest>',
  608. ' <Area Id="2800" Type="LA District">Epping</Area>',
  609. ' </contest>',
  610. ' <contest>',
  611. ' <Area Id="2900" Type="LA District">Fairfield</Area>',
  612. ' </contest>',
  613. ' <contest>',
  614. ' <Area Id="3000" Type="LA District">Gosford</Area>',
  615. ' </contest>',
  616. ' <contest>',
  617. ' <Area Id="3100" Type="LA District">Goulburn</Area>',
  618. ' </contest>',
  619. ' <contest>',
  620. ' <Area Id="3200" Type="LA District">Granville</Area>',
  621. ' </contest>',
  622. ' <contest>',
  623. ' <Area Id="3300" Type="LA District">Hawkesbury</Area>',
  624. ' </contest>',
  625. ' <contest>',
  626. ' <Area Id="3400" Type="LA District">Heathcote</Area>',
  627. ' </contest>',
  628. ' <contest>',
  629. ' <Area Id="3500" Type="LA District">Heffron</Area>',
  630. ' </contest>',
  631. ' <contest>',
  632. ' <Area Id="3600" Type="LA District">Hornsby</Area>',
  633. ' </contest>',
  634. ' <contest>',
  635. ' <Area Id="3700" Type="LA District">Keira</Area>',
  636. ' </contest>',
  637. ' <contest>',
  638. ' <Area Id="3800" Type="LA District">Kiama</Area>',
  639. ' </contest>',
  640. ' <contest>',
  641. ' <Area Id="3900" Type="LA District">Kogarah</Area>',
  642. ' </contest>',
  643. ' <contest>',
  644. ' <Area Id="4000" Type="LA District">Ku-ring-gai</Area>',
  645. ' </contest>',
  646. ' <contest>',
  647. ' <Area Id="4100" Type="LA District">Lake Macquarie</Area>',
  648. ' </contest>',
  649. ' <contest>',
  650. ' <Area Id="4200" Type="LA District">Lakemba</Area>',
  651. ' </contest>',
  652. ' <contest>',
  653. ' <Area Id="4300" Type="LA District">Lane Cove</Area>',
  654. ' </contest>',
  655. ' <contest>',
  656. ' <Area Id="4400" Type="LA District">Lismore</Area>',
  657. ' </contest>',
  658. ' <contest>',
  659. ' <Area Id="4500" Type="LA District">Liverpool</Area>',
  660. ' </contest>',
  661. ' <contest>',
  662. ' <Area Id="4600" Type="LA District">Londonderry</Area>',
  663. ' </contest>',
  664. ' <contest>',
  665. ' <Area Id="4700" Type="LA District">Macquarie Fields</Area>',
  666. ' </contest>',
  667. ' <contest>',
  668. ' <Area Id="4800" Type="LA District">Maitland</Area>',
  669. ' </contest>',
  670. ' <contest>',
  671. ' <Area Id="4900" Type="LA District">Manly</Area>',
  672. ' </contest>',
  673. ' <contest>',
  674. ' <Area Id="5000" Type="LA District">Maroubra</Area>',
  675. ' </contest>',
  676. ' <contest>',
  677. ' <Area Id="5100" Type="LA District">Marrickville</Area>',
  678. ' </contest>',
  679. ' <contest>',
  680. ' <Area Id="5200" Type="LA District">Menai</Area>',
  681. ' </contest>',
  682. ' <contest>',
  683. ' <Area Id="5300" Type="LA District">Miranda</Area>',
  684. ' </contest>',
  685. ' <contest>',
  686. ' <Area Id="5400" Type="LA District">Monaro</Area>',
  687. ' </contest>',
  688. ' <contest>',
  689. ' <Area Id="5500" Type="LA District">Mount Druitt</Area>',
  690. ' </contest>',
  691. ' <contest>',
  692. ' <Area Id="5600" Type="LA District">Mulgoa</Area>',
  693. ' </contest>',
  694. ' <contest>',
  695. ' <Area Id="5700" Type="LA District">Murray-Darling</Area>',
  696. ' </contest>',
  697. ' <contest>',
  698. ' <Area Id="5800" Type="LA District">Murrumbidgee</Area>',
  699. ' </contest>',
  700. ' <contest>',
  701. ' <Area Id="5900" Type="LA District">Myall Lakes</Area>',
  702. ' </contest>',
  703. ' <contest>',
  704. ' <Area Id="6000" Type="LA District">Newcastle</Area>',
  705. ' </contest>',
  706. ' <contest>',
  707. ' <Area Id="6100" Type="LA District">North Shore</Area>',
  708. ' </contest>',
  709. ' <contest>',
  710. ' <Area Id="6200" Type="LA District">Northern Tablelands</Area>',
  711. ' </contest>',
  712. ' <contest>',
  713. ' <Area Id="6300" Type="LA District">Oatley</Area>',
  714. ' </contest>',
  715. ' <contest>',
  716. ' <Area Id="6400" Type="LA District">Orange</Area>',
  717. ' </contest>',
  718. ' <contest>',
  719. ' <Area Id="6500" Type="LA District">Oxley</Area>',
  720. ' </contest>',
  721. ' <contest>',
  722. ' <Area Id="6600" Type="LA District">Parramatta</Area>',
  723. ' </contest>',
  724. ' <contest>',
  725. ' <Area Id="6700" Type="LA District">Penrith</Area>',
  726. ' </contest>',
  727. ' <contest>',
  728. ' <Area Id="6800" Type="LA District">Pittwater</Area>',
  729. ' </contest>',
  730. ' <contest>',
  731. ' <Area Id="6900" Type="LA District">Port Macquarie</Area>',
  732. ' </contest>',
  733. ' <contest>',
  734. ' <Area Id="7000" Type="LA District">Port Stephens</Area>',
  735. ' </contest>',
  736. ' <contest>',
  737. ' <Area Id="7100" Type="LA District">Riverstone</Area>',
  738. ' </contest>',
  739. ' <contest>',
  740. ' <Area Id="7200" Type="LA District">Rockdale</Area>',
  741. ' </contest>',
  742. ' <contest>',
  743. ' <Area Id="7300" Type="LA District">Ryde</Area>',
  744. ' </contest>',
  745. ' <contest>',
  746. ' <Area Id="7400" Type="LA District">Shellharbour</Area>',
  747. ' </contest>',
  748. ' <contest>',
  749. ' <Area Id="7500" Type="LA District">Smithfield</Area>',
  750. ' </contest>',
  751. ' <contest>',
  752. ' <Area Id="7600" Type="LA District">South Coast</Area>',
  753. ' </contest>',
  754. ' <contest>',
  755. ' <Area Id="7700" Type="LA District">Strathfield</Area>',
  756. ' </contest>',
  757. ' <contest>',
  758. ' <Area Id="7800" Type="LA District">Swansea</Area>',
  759. ' </contest>',
  760. ' <contest>',
  761. ' <Area Id="7900" Type="LA District">Sydney</Area>',
  762. ' </contest>',
  763. ' <contest>',
  764. ' <Area Id="8000" Type="LA District">Tamworth</Area>',
  765. ' </contest>',
  766. ' <contest>',
  767. ' <Area Id="8100" Type="LA District">Terrigal</Area>',
  768. ' </contest>',
  769. ' <contest>',
  770. ' <Area Id="8200" Type="LA District">The Entrance</Area>',
  771. ' </contest>',
  772. ' <contest>',
  773. ' <Area Id="8300" Type="LA District">Toongabbie</Area>',
  774. ' </contest>',
  775. ' <contest>',
  776. ' <Area Id="8400" Type="LA District">Tweed</Area>',
  777. ' </contest>',
  778. ' <contest>',
  779. ' <Area Id="8500" Type="LA District">Upper Hunter</Area>',
  780. ' </contest>',
  781. ' <contest>',
  782. ' <Area Id="8600" Type="LA District">Vaucluse</Area>',
  783. ' </contest>',
  784. ' <contest>',
  785. ' <Area Id="8700" Type="LA District">Wagga Wagga</Area>',
  786. ' </contest>',
  787. ' <contest>',
  788. ' <Area Id="8800" Type="LA District">Wakehurst</Area>',
  789. ' </contest>',
  790. ' <contest>',
  791. ' <Area Id="8900" Type="LA District">Wallsend</Area>',
  792. ' </contest>',
  793. ' <contest>',
  794. ' <Area Id="9000" Type="LA District">Willoughby</Area>',
  795. ' </contest>',
  796. ' <contest>',
  797. ' <Area Id="9100" Type="LA District">Wollondilly</Area>',
  798. ' </contest>',
  799. ' <contest>',
  800. ' <Area Id="9200" Type="LA District">Wollongong</Area>',
  801. ' </contest>',
  802. ' <contest>',
  803. ' <Area Id="9300" Type="LA District">Wyong</Area>',
  804. ' </contest>',
  805. ' </Election>',
  806. ' <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>KRK0/Hnx6VMJdEycg9JSKM5RbCL/iXbvrXKdfjoAXpU=</DigestValue></Reference></SignedInfo><SignatureValue>ah0dEIsFANQFtXXNghqQ39ll6l6Nh4tE16/Tm0BnEaWd/GhdtzrGBszed+ugnpcqFYje4rm2fW8a',
  807. 'BihAsFz7A748B27fu8yBQbqG6qiSGkiH+51aRJtLl7MxYEB1w614Lq4t1zzVjWLu/9BaS2Op3dSg',
  808. 'wcw1xDVBaJg5k9gGiQ0qDbMcQfMFmycwShWpu45O62ezUsEn8Jw54qap5Tfg+7vklSSqh7OURnrb',
  809. '84+3GOjwy4ML3kLRbNI8iksjoQUSa8j5zYOsTdWIewnjgb5jn/YgIUZPcZFnca5SE+i1IkmzZxD5',
  810. 'ztCMeqxKpFcQpIVHGL81fpwxL5cterxDq8uzwA==</SignatureValue></Signature></ElectionEvent>',
  811. '</xml>'
  812. ].join('\n');
  813. var publicKeyPem = [
  814. '-----BEGIN PUBLIC KEY-----',
  815. 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2yUCdVp5rCWUae2wpR3f',
  816. 'r6TNFj/sz7to9ATk++gQ69iEHLTqHz38JLT4So74peGXX1VzVNGLOi1o5kTGmoDN',
  817. 'erj0bO8h2FTyXTn73R0C8oyNGfI+WcloO8uHLn5GktMxweYtVfAgvkm0k9P44K2K',
  818. 'WMQq1jkdvNu2ItZN4DXdADfeEstB3d/XtRZ6Q2xaQCgGytSGeejnToNMEzid7vr2',
  819. 'zctWfcLYJ9ljon33pzJbkfu14I4/amLd8bVNxAZ55JyDRUghjll0xz41AyGpXApu',
  820. 'MeChOJkKYl4UfYH330syGHcqETEGh9akJJg+kUXeDVwn4qS08EnG4qOhEDs1Od8K',
  821. 'qQIDAQAB', '-----END PUBLIC KEY-----'
  822. ].join('\n');
  823. var signatureParentNode = 'xml/ElectionEvent/Signature';
  824. // get the public key
  825. var publicKey = forge.pki.publicKeyFromPem(publicKeyPem);
  826. // test it
  827. var verified = box.asymmetric.service.verifyXmlSignature(
  828. publicKey, inStream, signatureParentNode);
  829. expect(verified).toBeTruthy();
  830. });
  831. });
  832. it('verifies a xml using public key', function() {
  833. cryptolib('asymmetric.service', 'commons.utils', function(box) {
  834. var inStream = [
  835. '<?xml version="1.0" encoding="UTF-8"?>',
  836. '<EML xmlns="urn:oasis:names:tc:evs:schema:eml" xmlns:nswec="urn:nswec:events:emlExtension" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:xnl="urn:oasis:names:tc:ciq:xsdschema:xNL:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="410-ballots-v5-0" SchemaVersion="5.0" xsi:schemaLocation="urn:oasis:names:tc:evs:schema:eml http://docs.oasis-open.org/election/eml/v5.0/os/EML-Schemas-v5.0/410-ballots-v5-0.xsd urn:nswec:events:emlExtension http://www.elections.nsw.gov.au/standards/XML/emlcore-v5-0-NSWEC.xsd">',
  837. ' <TransactionId>5.04100001228337</TransactionId>',
  838. ' <SequenceNumber>78</SequenceNumber>',
  839. ' <NumberInSequence>94</NumberInSequence>',
  840. ' <SequencedElementName>Summer-Hill</SequencedElementName>',
  841. ' <ManagingAuthority>',
  842. ' <AuthorityIdentifier Id="EMS.ID.0007649">Returning Office for Summer Hill</AuthorityIdentifier>',
  843. ' <AuthorityAddress>',
  844. ' <xal:AddressLines>',
  845. ' <xal:AddressLine Type="AddressName">Summer Hill Returning Office</xal:AddressLine>',
  846. ' <xal:AddressLine Type="AddressLine1">Ground Floor Suite 1</xal:AddressLine>',
  847. ' <xal:AddressLine Type="AddressLine2">109 Jessie Street</xal:AddressLine>',
  848. ' <xal:AddressLine Type="LocalityName">Summer Hill</xal:AddressLine>',
  849. ' <xal:AddressLine Type="State">NSW</xal:AddressLine>',
  850. ' <xal:AddressLine Type="Postcode">2378</xal:AddressLine>',
  851. ' <xal:AddressLine Type="Country">Australia</xal:AddressLine>',
  852. ' </xal:AddressLines>',
  853. ' </AuthorityAddress>',
  854. ' <ResponsibleOfficer Id="00000000000000281210">',
  855. ' <Responsibility>Returning Officer for Summer Hill</Responsibility>',
  856. ' <Name>',
  857. ' <xnl:PersonName>',
  858. ' <xnl:FirstName>Peter</xnl:FirstName>',
  859. ' <xnl:LastName>Dooley</xnl:LastName>',
  860. ' </xnl:PersonName>',
  861. ' </Name>',
  862. ' <Contact>',
  863. ' <MailingAddress>',
  864. ' <xal:AddressLines>',
  865. ' <xal:AddressLine Type="AddressName">Summer Hill Returning Officer Office</xal:AddressLine>',
  866. ' <xal:AddressLine Type="AddressLine1">PO Box 629</xal:AddressLine>',
  867. ' <xal:AddressLine Type="LocalityName">Summer Hill</xal:AddressLine>',
  868. ' <xal:AddressLine Type="State">NSW</xal:AddressLine>',
  869. ' <xal:AddressLine Type="Postcode">2378</xal:AddressLine>',
  870. ' <xal:AddressLine Type="Country">Australia</xal:AddressLine>',
  871. ' </xal:AddressLines>',
  872. ' </MailingAddress>',
  873. ' <Email>RO.Summer_Hill@elections.nsw.gov.au</Email>',
  874. ' <Telephone Preferred="no">',
  875. ' <Number>0267727755</Number>',
  876. ' </Telephone>',
  877. ' <Telephone Preferred="yes">',
  878. ' <Number>1300135736</Number>',
  879. ' </Telephone>',
  880. ' </Contact>',
  881. ' </ResponsibleOfficer>',
  882. ' </ManagingAuthority>',
  883. ' <IssueDate>2014-11-17</IssueDate>',
  884. ' <Ballots>',
  885. ' <EventIdentifier Id="SG1409-078">',
  886. ' <EventName>Summer Hill</EventName>',
  887. ' <EventQualifier Id="SG1409">NSW State General Election 2014</EventQualifier>',
  888. ' </EventIdentifier>',
  889. ' <Ballot>',
  890. ' <Election>',
  891. ' <ElectionIdentifier Id="SG1409-078-01">',
  892. ' <ElectionName>Legislative Assembly Election</ElectionName>',
  893. ' <ElectionCategory>Parliamentary</ElectionCategory>',
  894. ' </ElectionIdentifier>',
  895. ' <Description>',
  896. ' <Message>Ballot Paper</Message>',
  897. ' </Description>',
  898. ' <Contest>',
  899. ' <ContestIdentifier Id="SG1409-078-01-00">',
  900. ' <ContestName>Summer Hill</ContestName>',
  901. ' </ContestIdentifier>',
  902. ' <HowToVote>',
  903. ' <Message Type="Preamble">DIRECTIONS FOR VOTING PLEASE READ CAREFULLY</Message>',
  904. ' <Message Type="SoleOption">Write the number 1 in the square next to the candidate of your choice. You can show more choices, if you want to, by writing numbers in the other squares, starting with the number 2.</Message>',
  905. ' <Message Type="SoleOption-AfterVoting">Fold this ballot paper so your vote cannot be seen and place it in the ballot box (or in the envelope provided).</Message>',
  906. ' </HowToVote>',
  907. ' <VotingMethod>OPV</VotingMethod>',
  908. ' <MaxVotes>7',
  909. '</MaxVotes>',
  910. ' <MinVotes>1</MinVotes>',
  911. ' <BallotChoices>',
  912. '<Candidate><CandidateIdentifier Id="1"><CandidateName>REN George</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__REN_George"><xnl:PersonName><xnl:FirstName NameType="Given Name">George</xnl:FirstName><xnl:LastName NameType="Surname">REN</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>INDEPENDENT</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  913. '<Candidate><CandidateIdentifier Id="2"><CandidateName>TOMLINSON Richard</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__TOMLINSON_Richard"><xnl:PersonName><xnl:FirstName NameType="Given Name">Richard</xnl:FirstName><xnl:LastName NameType="Surname">TOMLINSON</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>DEMOCRATIC PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  914. '<Candidate><CandidateIdentifier Id="3"><CandidateName>WILLIAMS Mark</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__WILLIAMS_Mark"><xnl:PersonName><xnl:FirstName NameType="Given Name">Mark</xnl:FirstName><xnl:LastName NameType="Surname">WILLIAMS</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>THE KHAKI PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  915. '<Candidate><CandidateIdentifier Id="4"><CandidateName>ADCOCK Ben</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__ADCOCK_Ben"><xnl:PersonName><xnl:FirstName NameType="Given Name">Ben</xnl:FirstName><xnl:LastName NameType="Surname">ADCOCK</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>CONSERVATIVES</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  916. '<Candidate><CandidateIdentifier Id="5"><CandidateName>YONG Mike</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__YONG_Mike"><xnl:PersonName><xnl:FirstName NameType="Given Name">Mike</xnl:FirstName><xnl:LastName NameType="Surname">YONG</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>AUSTRALIANS FOR ADVANCEMENT</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  917. '<Candidate><CandidateIdentifier Id="6"><CandidateName>WITHERS John</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__WITHERS_John"><xnl:PersonName><xnl:FirstName NameType="Given Name">John</xnl:FirstName><xnl:LastName NameType="Surname">WITHERS</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>THE RELIGIOUS PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  918. '<Candidate><CandidateIdentifier Id="7"><CandidateName>CALLAGHAN Paul</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__CALLAGHAN_Paul"><xnl:PersonName><xnl:FirstName NameType="Given Name">Paul</xnl:FirstName><xnl:LastName NameType="Surname">CALLAGHAN</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>WORKING PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  919. ' </BallotChoices>',
  920. ' <nswec:ContestDescription>Election of Member of Parliamant</nswec:ContestDescription>',
  921. ' <nswec:NumberOfPositionsContested>1</nswec:NumberOfPositionsContested>',
  922. ' <nswec:PrintStatus ReprintRequired="yes">',
  923. ' <nswec:DrawComplete>2014-11-17T16:28:01</nswec:DrawComplete>',
  924. ' <nswec:Previous410/>',
  925. ' </nswec:PrintStatus>',
  926. ' </Contest>',
  927. ' </Election>',
  928. ' </Ballot>',
  929. ' </Ballots>',
  930. '<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>mhCdaEEiuFgKJd0sBooryGBx2b9xwsF1rlX3MSDu83c=</DigestValue></Reference></SignedInfo><SignatureValue>Gu87GxyWKAu9D3fhQkjy3EcgaycGylVEmTOqW6HRXvTy+XbduWaazTfnnTjR/C7wig8+kbckXEkz',
  931. 'B81FBCmUJibugK6eRWkcrJPmrds5LwCQXL+4zmwmISA1pKyuGhLoGlcdupKCdT98pLmD7cauje8P',
  932. 'bOstRTTz5mgBqbQN9O91RMzjdov6mq53l3m4BVG4lFmxoG5L/PQ989G7vMM/K3yPQ1fCVWqguzBN',
  933. 'Dve+OtbiIOSF2kGmXtQ+qAUCdXNmYt+JamoU6BIsHgIiyRk9C0NKs5S2lvewJonJtf+9lLkU2OLU',
  934. 'FN5hFpgtWNCglHJsg0rtIFJN4fLJwK6RNpi29A==</SignatureValue></Signature></EML>'
  935. ].join('\n');
  936. var publicKeyPem = [
  937. '-----BEGIN PUBLIC KEY-----',
  938. 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAj8ZhcZnHuNfFc+C7KpSR',
  939. 'oaDmUf1XbT8haRQADcQF/04r5hbAsF6Kf+Nj+ulRNK6RGxeLhtlYTyqTCdJeZUQj',
  940. '5lHuIAK99D2rknytEZ7tAM4u36SGlICdAanz7DxGMUFGa+xUCFmTaSfX1BJGn3Qi',
  941. '/vB/LMdPjrOd/7UISHH93D2fB5iX2qGxw4D3iVWUOXJunx48nduC3AFqCLDmlX6F',
  942. 'ongfsOBImQwgcpM3nEtYr3JWAC7D66Y6ocBXQ/OATwCbJ5jGRY6RjldMjc207iOw',
  943. 'HxTpZeIPHM9UyGeqd3QbKPHQquzBF8ytgssfFwGLIxhRQFwGy9kpy6l8HIHHRf7l',
  944. 'BQIDAQAB', '-----END PUBLIC KEY-----'
  945. ].join('\n');
  946. var publicKey = forge.pki.publicKeyFromPem(publicKeyPem);
  947. var signatureParentNode = 'EML/Signature';
  948. // test it
  949. var verified = box.asymmetric.service.verifyXmlSignature(
  950. publicKey, inStream, signatureParentNode);
  951. expect(verified).toBeTruthy();
  952. });
  953. });
  954. it('verifies the same xml as previous test, but signed with a different private key', function() {
  955. cryptolib('asymmetric.service', 'commons.utils', function(box) {
  956. var inStream = [
  957. '<?xml version="1.0" encoding="UTF-8"?>',
  958. '<EML xmlns="urn:oasis:names:tc:evs:schema:eml" xmlns:nswec="urn:nswec:events:emlExtension" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:xnl="urn:oasis:names:tc:ciq:xsdschema:xNL:2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Id="410-ballots-v5-0" SchemaVersion="5.0" xsi:schemaLocation="urn:oasis:names:tc:evs:schema:eml http://docs.oasis-open.org/election/eml/v5.0/os/EML-Schemas-v5.0/410-ballots-v5-0.xsd urn:nswec:events:emlExtension http://www.elections.nsw.gov.au/standards/XML/emlcore-v5-0-NSWEC.xsd">',
  959. ' <TransactionId>5.04100001228337</TransactionId>',
  960. ' <SequenceNumber>78</SequenceNumber>',
  961. ' <NumberInSequence>94</NumberInSequence>',
  962. ' <SequencedElementName>Summer-Hill</SequencedElementName>',
  963. ' <ManagingAuthority>',
  964. ' <AuthorityIdentifier Id="EMS.ID.0007649">Returning Office for Summer Hill</AuthorityIdentifier>',
  965. ' <AuthorityAddress>',
  966. ' <xal:AddressLines>',
  967. ' <xal:AddressLine Type="AddressName">Summer Hill Returning Office</xal:AddressLine>',
  968. ' <xal:AddressLine Type="AddressLine1">Ground Floor Suite 1</xal:AddressLine>',
  969. ' <xal:AddressLine Type="AddressLine2">109 Jessie Street</xal:AddressLine>',
  970. ' <xal:AddressLine Type="LocalityName">Summer Hill</xal:AddressLine>',
  971. ' <xal:AddressLine Type="State">NSW</xal:AddressLine>',
  972. ' <xal:AddressLine Type="Postcode">2378</xal:AddressLine>',
  973. ' <xal:AddressLine Type="Country">Australia</xal:AddressLine>',
  974. ' </xal:AddressLines>',
  975. ' </AuthorityAddress>',
  976. ' <ResponsibleOfficer Id="00000000000000281210">',
  977. ' <Responsibility>Returning Officer for Summer Hill</Responsibility>',
  978. ' <Name>',
  979. ' <xnl:PersonName>',
  980. ' <xnl:FirstName>Peter</xnl:FirstName>',
  981. ' <xnl:LastName>Dooley</xnl:LastName>',
  982. ' </xnl:PersonName>',
  983. ' </Name>',
  984. ' <Contact>',
  985. ' <MailingAddress>',
  986. ' <xal:AddressLines>',
  987. ' <xal:AddressLine Type="AddressName">Summer Hill Returning Officer Office</xal:AddressLine>',
  988. ' <xal:AddressLine Type="AddressLine1">PO Box 629</xal:AddressLine>',
  989. ' <xal:AddressLine Type="LocalityName">Summer Hill</xal:AddressLine>',
  990. ' <xal:AddressLine Type="State">NSW</xal:AddressLine>',
  991. ' <xal:AddressLine Type="Postcode">2378</xal:AddressLine>',
  992. ' <xal:AddressLine Type="Country">Australia</xal:AddressLine>',
  993. ' </xal:AddressLines>',
  994. ' </MailingAddress>',
  995. ' <Email>RO.Summer_Hill@elections.nsw.gov.au</Email>',
  996. ' <Telephone Preferred="no">',
  997. ' <Number>0267727755</Number>',
  998. ' </Telephone>',
  999. ' <Telephone Preferred="yes">',
  1000. ' <Number>1300135736</Number>',
  1001. ' </Telephone>',
  1002. ' </Contact>',
  1003. ' </ResponsibleOfficer>',
  1004. ' </ManagingAuthority>',
  1005. ' <IssueDate>2014-11-17</IssueDate>',
  1006. ' <Ballots>',
  1007. ' <EventIdentifier Id="SG1409-078">',
  1008. ' <EventName>Summer Hill</EventName>',
  1009. ' <EventQualifier Id="SG1409">NSW State General Election 2014</EventQualifier>',
  1010. ' </EventIdentifier>',
  1011. ' <Ballot>',
  1012. ' <Election>',
  1013. ' <ElectionIdentifier Id="SG1409-078-01">',
  1014. ' <ElectionName>Legislative Assembly Election</ElectionName>',
  1015. ' <ElectionCategory>Parliamentary</ElectionCategory>',
  1016. ' </ElectionIdentifier>',
  1017. ' <Description>',
  1018. ' <Message>Ballot Paper</Message>',
  1019. ' </Description>',
  1020. ' <Contest>',
  1021. ' <ContestIdentifier Id="SG1409-078-01-00">',
  1022. ' <ContestName>Summer Hill</ContestName>',
  1023. ' </ContestIdentifier>',
  1024. ' <HowToVote>',
  1025. ' <Message Type="Preamble">DIRECTIONS FOR VOTING PLEASE READ CAREFULLY</Message>',
  1026. ' <Message Type="SoleOption">Write the number 1 in the square next to the candidate of your choice. You can show more choices, if you want to, by writing numbers in the other squares, starting with the number 2.</Message>',
  1027. ' <Message Type="SoleOption-AfterVoting">Fold this ballot paper so your vote cannot be seen and place it in the ballot box (or in the envelope provided).</Message>',
  1028. ' </HowToVote>',
  1029. ' <VotingMethod>OPV</VotingMethod>',
  1030. ' <MaxVotes>7',
  1031. '</MaxVotes>',
  1032. ' <MinVotes>1</MinVotes>',
  1033. ' <BallotChoices>',
  1034. '<Candidate><CandidateIdentifier Id="1"><CandidateName>REN George</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__REN_George"><xnl:PersonName><xnl:FirstName NameType="Given Name">George</xnl:FirstName><xnl:LastName NameType="Surname">REN</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>INDEPENDENT</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  1035. '<Candidate><CandidateIdentifier Id="2"><CandidateName>TOMLINSON Richard</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__TOMLINSON_Richard"><xnl:PersonName><xnl:FirstName NameType="Given Name">Richard</xnl:FirstName><xnl:LastName NameType="Surname">TOMLINSON</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>DEMOCRATIC PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  1036. '<Candidate><CandidateIdentifier Id="3"><CandidateName>WILLIAMS Mark</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__WILLIAMS_Mark"><xnl:PersonName><xnl:FirstName NameType="Given Name">Mark</xnl:FirstName><xnl:LastName NameType="Surname">WILLIAMS</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>THE KHAKI PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  1037. '<Candidate><CandidateIdentifier Id="4"><CandidateName>ADCOCK Ben</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__ADCOCK_Ben"><xnl:PersonName><xnl:FirstName NameType="Given Name">Ben</xnl:FirstName><xnl:LastName NameType="Surname">ADCOCK</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>CONSERVATIVES</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  1038. '<Candidate><CandidateIdentifier Id="5"><CandidateName>YONG Mike</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__YONG_Mike"><xnl:PersonName><xnl:FirstName NameType="Given Name">Mike</xnl:FirstName><xnl:LastName NameType="Surname">YONG</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>AUSTRALIANS FOR ADVANCEMENT</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  1039. '<Candidate><CandidateIdentifier Id="6"><CandidateName>WITHERS John</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__WITHERS_John"><xnl:PersonName><xnl:FirstName NameType="Given Name">John</xnl:FirstName><xnl:LastName NameType="Surname">WITHERS</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>THE RELIGIOUS PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  1040. '<Candidate><CandidateIdentifier Id="7"><CandidateName>CALLAGHAN Paul</CandidateName></CandidateIdentifier><CandidateFullName nswec:EventGroupUniqueId="SG1409_Summer_Hill_General_LA__CALLAGHAN_Paul"><xnl:PersonName><xnl:FirstName NameType="Given Name">Paul</xnl:FirstName><xnl:LastName NameType="Surname">CALLAGHAN</xnl:LastName></xnl:PersonName></CandidateFullName><Affiliation><AffiliationIdentifier><RegisteredName>WORKING PARTY</RegisteredName></AffiliationIdentifier><Type>Party</Type></Affiliation></Candidate>',
  1041. ' </BallotChoices>',
  1042. ' <nswec:ContestDescription>Election of Member of Parliamant</nswec:ContestDescription>',
  1043. ' <nswec:NumberOfPositionsContested>1</nswec:NumberOfPositionsContested>',
  1044. ' <nswec:PrintStatus ReprintRequired="yes">',
  1045. ' <nswec:DrawComplete>2014-11-17T16:28:01</nswec:DrawComplete>',
  1046. ' <nswec:Previous410/>',
  1047. ' </nswec:PrintStatus>',
  1048. ' </Contest>',
  1049. ' </Election>',
  1050. ' </Ballot>',
  1051. ' </Ballots>',
  1052. '<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/><SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><Reference URI=""><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>mhCdaEEiuFgKJd0sBooryGBx2b9xwsF1rlX3MSDu83c=</DigestValue></Reference></SignedInfo><SignatureValue>AKJSep65koofOLMS3qjTc1m7qdFxj9atHmMbCdjiMDhUp26kxRjuP7XEETs6njU/Hg9IdYNUAxJi',
  1053. '0lwsK7cA0tI8MjS6JbRBXaewSTLOrZQAfqQiGJA/99qSJqPFus66XQTplzzLdzSVn7y2O4bwqU4m',
  1054. 'knuxU4J5kI9dX+OSLl0=</SignatureValue></Signature></EML>'
  1055. ].join('\n');
  1056. var publicKeyPem = [
  1057. '-----BEGIN PUBLIC KEY-----',
  1058. 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDEv0nlMpUDbILYCdCttYa6xrqN',
  1059. 'upJeMdNjs7Z9UBLnjYYK520yuCbDGoOoUUA0FImG8rQ66xSOR7HoyZLebFS3tPuu',
  1060. 'NCnYUIvGiMARRTLbFtE7QeGGdZRDfixtQqEznfEAY4lDb/+JsDV3gGC1pPV1kkWp',
  1061. 'HW4qwJ35m3mseEM2dQIDAQAB', '-----END PUBLIC KEY-----'
  1062. ].join('\n');
  1063. var publicKey = forge.pki.publicKeyFromPem(publicKeyPem);
  1064. var signatureParentNode = 'EML/Signature';
  1065. // test it
  1066. var verified = box.asymmetric.service.verifyXmlSignature(
  1067. publicKey, inStream, signatureParentNode);
  1068. expect(verified).toBeTruthy();
  1069. });
  1070. });
  1071. });
  1072. });