DigestValue of the xml document in php -


could please me how accomplish correct digestvalue in xml document? have xml examples creator, somehow cannot generate same sha256 hash in php.

the documentation says <soap:body> should hashed using sha256 algorithm. well, understand need to

  1. canonicalize xml (c14n)
  2. create sha256 hash it
  3. base64 encode it

the hash result example should twpslqpoxsue8k6q8lad7dymhwkticbhnifrpnwdg/m=

how accomplish in php code below?

i tried this:

$xml='<soap:body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:id="id-ab79979f3364f5119a14761286403964"><trzba xmlns="http://fs.mfcr.cz/eet/schema/v3"><hlavicka dat_odesl="2016-09-19t19:06:37+02:00" prvni_zaslani="false" uuid_zpravy="ab1bc7a0-5ab0-4d61-a170-2982f2d83784"/><data celk_trzba="34113.00" cerp_zuct="679.00" cest_sluz="5460.00" dan1="-172.39" dan2="-530.73" dan3="975.65" dat_trzby="2016-08-05t00:30:12+02:00" dic_popl="cz1212121218" id_pokl="/5546/ro24" id_provoz="273" porad_cis="0/6460/zq42" pouzit_zboz1="784.00" pouzit_zboz2="967.00" pouzit_zboz3="189.00" rezim="0" urceno_cerp_zuct="324.00" zakl_dan1="-820.92" zakl_dan2="-3538.20" zakl_dan3="9756.46" zakl_nepodl_dph="3036.00"/><kontrolnikody><pkp cipher="rsa2048" digest="sha256" encoding="base64">jvcv0lxft74zuvijaheo91guufum1mkhq0nnpxw0ylbgviit+i4qxec3qp6brwekis14n2wn+9oq8nhqpywzx7l4w9ie7cyv1ojcl/yif4560edb3iprnrj3ujqlwsz5ucsm9vwqp0utbhjdsuk5/wjc/ceisyv7oqiqa0nj0f0+ldzgvelrsf34eu2iqahs/yfdnenlnmdpvb5ko/zqo0vcc93k5deweoyttiaskd6jkso7eama8qe+d0wq9vbzudkflgce2c1ierjuyhknhjo9kox10h5wk99qqvgx8tthpamrydcx2n0zgkzjhuzzebnysxxfyi2tkojlillolq==</pkp><bkp digest="sha1" encoding="base16">3f9119c1-fbf34535-d30b60f8-9859e4a6-c8c8aafa</bkp></kontrolnikody></trzba></soap:body>'; $doc = new domdocument('1.0','utf-8'); $doc->loadxml($xml); echo base64_encode(hash('sha256',$doc->c14n(true),true)); 

but returning me other hash value :-( maybe taking wrong part of xml source. ideas part of text/how did count hash , how have same result in php? whole working example (taken [http://www.etrzby.cz/assets/cs/prilohy/cz1212121218.valid.v3.1.xml) this:

<?xml version="1.0" encoding="utf-8"?><soap:envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:header xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><wsse:security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soap:mustunderstand="1"><wsse:binarysecuritytoken encodingtype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#base64binary" valuetype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#x509v3" wsu:id="x509-a79845f15c5549ca0514761283545351">miiemdcca4cgawibagiedhoxjzanbgkqhkig9w0baqsfadb3mriweaykczimizpylgqbgrycq1oxqzbbbgnvbaomossmzxnrw6egumvwdwjsawthiokakybhzw5lcsohbg7drsbmaw5hbssnbsotimwzzwrpdgvsc3r2w60xhdaabgnvbamte0vfvcbdqsaxifbsyxlncm91bmqwhhcnmtywotmwmdkwmzu5whcnmtkwotmwmdkwmzu5wjbdmriweaykczimizpylgqbgrycq1oxezarbgnvbamtcknamdawmdawmtkxgdawbgnvba0td3byyxzuawnrysbvc29iytccasiwdqyjkozihvcnaqebbqadggepadccaqocggebajnnupw8ralli2kawu12w1vqlj02mwiifq/jp0/tujf9b8rpkdad3goqddvuhsfxej92wieoudy7x8uxziddzu4pxa3t3kntxm8ralu2u6sqtf3ktr+ajcdwfkm53u3z4/qoykqdq8lgumxjks7x5uijcy/udsxmk9otmxrhndjycx1oilr5f2onf1z0kwyl/s9wi0cl0gq1f91mzqgnlh80u2inmmmbp42ndr4tgs1nvjer5d73bklg07tdeqnug609wwjujn96okzmskxzbmzt09nbhqcabwnawbrtsvhsaddo8vfmwx2c+gxulkivto+9fbj81gs1xdnoakparuccaweaaaocav4wggfamakga1udewqcmaawhqydvr0obbyefl/0b0iw6fy33ut8ijey1v7nzvr6mb8ga1udiwqymbaafhwwdqzm1ofr7mkf4nailonf3gwhma4ga1uddweb/wqeawigwdbjbgnvhsaexdbamfggcmcgsaflawibmaewsjbibggrbgefbqccaja8ddpuzw50bybjzxj0awzpa8ohdcbiewwgdnlkw6fuihbvdxplihbybyb0zxn0b3zhy8otimo6xi1lbhkumigxbgnvhr8egy8wgywwgymggyaggyogkwh0dha6ly9jcmwuy2exlxbnlmvldc5jei9lzxrjytfwzy9hbgwuy3jshipodhrwoi8vy3jsmi5jytetcgcuzwv0lmn6l2vldgnhmxbnl2fsbc5jcmygkmh0dha6ly9jcmwzlmnhms1wzy5lzxquy3ovzwv0y2excgcvywxslmnybdanbgkqhkig9w0baqsfaaocaqeavxdwsu+ibd1vysknjoy6rcyvci9+orusstvqqdjlfjwn5sm6hebhci8ergwazd2r6uqpdzl1kcjmhoitypz66e+/e9wj3badqgbkrzyvxzykavudtqgg0819jzmixtbggockiupixo80cnp7u1zpkvnv7wzwh0i2k/fg1vlti5ha/x4bed77wieoexa7eqepjet0jptvk3lxsw59llijroh4/kfkqbtvdl5ypw8wagamvcpvwngjicuru+aplu4pzd9bdhsa1ib4lpfhtwrkhym/xqkbj2bnkkjto5t3su0bf2qd3qzkmcjlnvg0v+qagimwtdpueu/mtexw+7z1/a==</wsse:binarysecuritytoken><ds:signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" id="sig-a79845f15c5549ca0514761283545705"><ds:signedinfo><ds:canonicalizationmethod algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:inclusivenamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" prefixlist="soap"/></ds:canonicalizationmethod><ds:signaturemethod algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/><ds:reference uri="#id-a79845f15c5549ca0514761283545594"><ds:transforms><ds:transform algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"><ec:inclusivenamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" prefixlist=""/></ds:transform></ds:transforms><ds:digestmethod algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:digestvalue>m8/dbi/lluwxp8zoerkvvpzihqhyudi0l6bglhnwkc0=</ds:digestvalue></ds:reference></ds:signedinfo><ds:signaturevalue>dlfif51sdtc0zeqgcsusy6eu5emx7hka6ox3gvir4dpqyrwj6o8cm4owkutl+erinf9cpog2y1z5y83+dubugmiopsaceezjwf5tcme/uu1tzxs+lsls8wxzvumuejforufeukyzrvhjw5lskv/dhimstwj/metgtjrvuwnaechxq/3alsc3hfsi/qaqaiglz3opikf3hai6iid37ejwhnd9qdjy4d32djwy4gw21ku7to3fildtbt+xdr3at8swbbihfwerkrutt/favqkffuzcjhdem9//w/shhufxydneh0m8cyp5z5xk2bfnfhakpb0ruzrrcw8t7llvzkgogg==</ds:signaturevalue><ds:keyinfo id="ki-a79845f15c5549ca0514761283545482"><wsse:securitytokenreference xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:id="str-a79845f15c5549ca0514761283545513"><wsse:reference uri="#x509-a79845f15c5549ca0514761283545351" valuetype="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#x509v3"/></wsse:securitytokenreference></ds:keyinfo></ds:signature></wsse:security></soap-env:header><soap:body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:id="id-a79845f15c5549ca0514761283545594"><trzba xmlns="http://fs.mfcr.cz/eet/schema/v3"><hlavicka dat_odesl="2016-08-19t19:06:37+02:00" prvni_zaslani="false" uuid_zpravy="2da635a5-d712-459d-9674-c12f335c39f7"/><data celk_trzba="34113.00" cerp_zuct="679.00" cest_sluz="5460.00" dan1="-172.39" dan2="-530.73" dan3="975.65" dat_trzby="2016-08-05t00:30:12+02:00" dic_popl="cz00000019" dic_poverujiciho="cz683555118" id_pokl="/5546/ro24" id_provoz="273" porad_cis="0/6460/zq42" pouzit_zboz1="784.00" pouzit_zboz2="967.00" pouzit_zboz3="189.00" rezim="0" urceno_cerp_zuct="324.00" zakl_dan1="-820.92" zakl_dan2="-3538.20" zakl_dan3="9756.46" zakl_nepodl_dph="3036.00"/><kontrolnikody><pkp cipher="rsa2048" digest="sha256" encoding="base64">a0aseijhfcblvtptsspkvezhcrvnzf7sq55c4dhnstnsu1b37gui2+dlme9p94ucpz1ocupjdsyobz3ix6aegee0fjkxyx0kxraycjkio3g64wrche7ibliobck1uhh8qqha66isnhb6hqboodlt2awo/0jczlfeqr0axppf1mohmnp3h3icaxzh0dnmdju5ommrq+91pl5t9kkr7bfghqaowj0kmxy/mzumtrfgil2/xf7i5pdveyxpgdo/tojzm6j95n68fpdoxtdrtzkymqdjpg3kmweplnqkfxrmkqrkbltojwg1ldudm3uttmpwzq4c0xngcxjdzglxfolgpa==</pkp><bkp digest="sha1" encoding="base16">9356d566-a3e48838-fb403790-d201244e-95dcbd92</bkp></kontrolnikody></trzba></soap:body></soap:envelope> 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -