473,395 Members | 1,797 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

xml dsig, how to save and hash reference elements?

AK
Hello,

I need to do the following with an xml document which has a list of
assets:
1. Hash the assets
2. Hash the element describing the assets
3. Create a digital signature (using X.509 certificate) over the
hashes from step 1 and 2

Most of the examples I've been looking at are doing a digital
signature in one go, and I'm not sure how to write the references with
the digest to the xml file without also creating a signature.

This is the code I currently have:

// Create a key container
CspParameters cspParameters = new CspParameters();
cspParameters.KeyContainerName = "XML_DSIG_RSA_KEY";

// Create an RSA key and save it in the container
RSACryptoServiceProvider rsaKey = new
RSACryptoServiceProvider(cspParameters);

// Create a new XML document and load the manifest into it
XmlDocument xmlDoc = new XmlDocument();
//xmlDoc.PreserveWhitespace = true;
xmlDoc.Load(manifestPath);

hashAssets(xmlDoc, rsaKey);

// Save the manifest
xmlDoc.Save(manifestPath);
public void hashAssets(XmlDocument Doc, RSA Key)
{
// Create a SignedXml object
SignedXml signedXml = new SignedXml(Doc);

// Add the key
signedXml.SigningKey = Key;

// Get urls to assets with signed = true
assetUris = getAssetUris();

foreach (string assetUri in assetUris)
{
// Create a reference to be signed
Reference reference = new Reference(); reference.Uri = assetUri;

//// Add an enveloped transformation to the reference
//XmlDsigEnvelopedSignatureTransform env = new
XmlDsigEnvelopedSignatureTransform();
//reference.AddTransform(env);

// Add the reference to the SignedXml object
signedXml.AddReference(reference);
}

// Compute the signature
signedXml.ComputeSignature();

// Get the XML representation of the signature and save it to an
XmlElement object
XmlElement xmlDigitalSignature = signedXml.GetXml();

// Append the element to the XML document
Doc.DocumentElement.AppendChild(Doc.ImportNode(xml DigitalSignature,
true));
}

Is there any way of saving the reference to the xmldoc without also
creating a signature? And then hash the reference elements and create
a signature over them? Or am I taking the wrong approach with this
code to start with?

Many thanks,

AK
Nov 4 '08 #1
0 2310

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hale | last post by:
Hi, I'm having a problem storing an array inside of a hash. I'm bringing in a hash via a reference and I want to assign a value to it. This is what I'm doing: push (@{$$node->{ELEMENTS}},...
2
by: Christopher | last post by:
I have a hash that is several levels deep. ie: 'vars' => { '$filers' => '10.10.10.10/32', '$networksa' => '10.10.10.10/32', '$networksb' => '10.50.0.0/16', '$wintel_boxes' =>...
22
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
4
by: Simone Battagliero | last post by:
I wrote a program which inserts and finds elements in an hash table. Each element of the table is a dinamic list, which holds all elements having the same hash value (calculated by an int...
6
by: Fred Morrison | last post by:
Do you know of a way to load a hash table with random key/value pairs (e.g., 2/"Two",1/"One",3/"Three") and then iterate through the entries in "sorted" (key sequence) order...
3
by: Markus Strobl | last post by:
Hi! I have a general question concerning xml digital signatures. Is XML-DSIG verifying that the content of the XML document isn't modified or does XML-DSIG really signs the binary...
4
by: Bo Peng | last post by:
Dear list, I am looking for a way to store a large amount of unique sequences that will be accessed by objects. The most important operations are: 1. Direct access to the sequences (from...
139
by: ravi | last post by:
Hi can anybody tell me that which ds will be best suited to implement a hash table in C/C++ thanx. in advanced
23
by: raylopez99 | last post by:
A quick sanity check, and I think I am correct, but just to make sure: if you have a bunch of objects that are very much like one another you can uniquely track them simply by using an ArrayList...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.