473,750 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.K eyContainerName = "XML_DSIG_RSA_K EY";

// Create an RSA key and save it in the container
RSACryptoServic eProvider rsaKey = new
RSACryptoServic eProvider(cspPa rameters);

// Create a new XML document and load the manifest into it
XmlDocument xmlDoc = new XmlDocument();
//xmlDoc.Preserve Whitespace = true;
xmlDoc.Load(man ifestPath);

hashAssets(xmlD oc, rsaKey);

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

// Add the key
signedXml.Signi ngKey = 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
//XmlDsigEnvelope dSignatureTrans form env = new
XmlDsigEnvelope dSignatureTrans form();
//reference.AddTr ansform(env);

// Add the reference to the SignedXml object
signedXml.AddRe ference(referen ce);
}

// Compute the signature
signedXml.Compu teSignature();

// Get the XML representation of the signature and save it to an
XmlElement object
XmlElement xmlDigitalSigna ture = signedXml.GetXm l();

// Append the element to the XML document
Doc.DocumentEle ment.AppendChil d(Doc.ImportNod e(xmlDigitalSig nature,
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 2359

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

Similar topics

1
11180
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}}, "New value"); (I need to use "push" because this is going in a for-loop)
2
5034
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' => '10.10.10.10/32', },
22
4640
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 month I had enough of extra proof that the cat doesn't hount mice anymore in more and more situations. And the surrent sicretisme among array and hash is the base for it. I summarized all points in this article:...
4
548
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 hashFunction(char *key, int elements) ), so the table is an array of dynamic lists. The version of the program I've attached to this message works fine; but it's the result of an accurate debugging. I discovered that my problems consisted in just 4 lines...
6
7829
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 (1/"One",2/"Two",3/"Three")? The following just returns them in the order they were loaded: Dim hshPrimaryKeyInfo as New Hashtable <snip code to Add entries to hash table> For Each hshEntry As DictionaryEntry In hshPrimaryKeyInfo
3
1285
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 representation of some data (mostly xml i guess). To make my question more clearly i have an example:
4
3159
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 pointers stored in each object). Access through key lookup is not acceptable. 2. Given a new sequence, determine if it is already in the factory of sequences. If so, increase the reference count of the existing sequence
139
14209
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
5741
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 or Array, correct? An example: create the object, create an array, the stuff the object into the array. Later on, assume the object is mutable, the object changes, but you can find it, if you have enough state information to uniquely identify...
0
9002
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8840
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9584
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9399
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9345
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6817
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6083
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4895
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2228
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.