3
When signing an XML, the signature generates the Digestvalue tag containing a Hash. I can generate Digest value with a digital certificate, but I would like to generate this hash without the need for a certificate...
I have seen in some documentation, that it is necessary to use SHA1 and Base64, but whenever I use these two algorithms, the hash that returns me is not the one I am expecting.
Does anyone know the complete algorithm to generate this value?
Setting:
- Input is any XML
- I use the SHA1 encryption algorithm, then
- I turn the return of encryption into Base64
- The return of Base64 should be the correct hash, but comes a different hash.
How is the code you use to generate and compare the hash? Can you post it? It’s hard to know what’s wrong without knowing exactly how you did it.
– Guilherme Bernal
I would like to know what the algorithm to generate this hash... I will edit the question describing the steps I make.
– fymoribe
An important step is to canonize XML. I recommend using the class Canonicalizer of the project Apache Santuario (actually, I wouldn’t do anything on hand, use this library for everything). On the algorithm just apply an SHA1 to get the bits (not the HEX signature) and on top of those bits get the Base64 of the signature. The library Apache Commons Codec has everything you need for the second part.
– Anthony Accioly
It is to encode in SHA1 and Conveter in Base64 I use these libraries you quoted.
– fymoribe