signature
「signature」とは、主に「署名(サイン)」や「署名すること」などを意味する英語の表現である。本人が自分の名前を(本人の証として)記すこと、および、そのようにして記された名前のこと。自筆署名に限らず、個人を判別できる特徴的なマークなどを指す場合もある。
日本語の名詞としての「サイン」は、英語では、「sign」よりも、むしろこの「signature」の意味に近い。
ちなみに「有名人のサイン」は、英語では普通「sign」でも「signature」でもなく「autograph(オートグラフ)」という。
「signature」は、典型的には、契約書や小切手などに書かれる「署名」を指す。この署名(signature)は、法的な効力を有する。ハンコ文化を持たない西欧では、signature がハンコの役割を持つわけである。
「signature」のスラングとしての意味
「signature」は、基本的には名詞として使われるが、形容詞として「代表的な」「自慢の」などの意味合いで使われることもある。例えば、「signature food(名物料理)」「signature soup(自慢のスープ)」などが挙げられる。ほかにも「signature」はスラングとして、カッコいい、ユニークという意味で用いられることがある。このような意味合いで使う場合、「signacha」と表記されることもある。
例
・Your outfit is so signacha !
(その服スゴくカッコいいね)
「signature(署名)」の意味で使われるスラング
アメリカ英語では「signature」の代わりに「John Hancock」という表現が、「署名」を指す語として用いられることがある。「John Hancock(ジョン・ハンコック)」は1776年の独立宣言に署名した人物である。大きな文字で目立つ署名だったことが知られている。いわば印象的なsignatureの代名詞のような扱いである。
例
・Can I have your John Hancock ?
(署名をお願いします)
「signature」の発音・読み方
「signature」の発音は /sígnətʃər/ である。カタカナ表記では「スィグネチャ」に近い発音である。日本語としては「シグネチャー」という表記が一般的に用いられている。
「signature」の特徴
「signature」には「特徴」という意味があり、行動や外観の特徴を表現するために使われる。ほかにも「特徴」という意味を持つ英単語として「character」が挙げられるが、こちらは精神的、感情的な特徴に対して用いられる。「signature」の語源・由来
「signature」の語源は、ラテン語で「署名する、印をつける」を意味する「signatus」である。それが中世ラテン語で「signatura」となり、16世紀の中頃「signature」となった。「signature」と「sign」の違い
「signature」と「sign」は品詞が違う。「signature」は名詞で「署名」、「sign」は動詞で「署名する」という意味である。「sign」は名詞としては「合図」「標識」「しるし」などを意味するが、「署名」という意味はない。・Please write your signature on this form.(この用紙に署名を記入してください)
・Please sign this form.(署名をしてください)
「signature」を含む英熟語・英語表現
「by signature」とは
「by signature」とは、「署名によって」という意味である。「affix one's signature to」とは
「affix one's signature to」とは、「~に署名する」という意味である。「affix one's signature to a contract」とすると「契約書に署名する」という意味になる。「time signature」とは
音楽における、拍子記号のことである。「signature」の使い方・例文
・He put his signature to the document.(彼は書類に署名した)・I need your signature on the dotted line. (点線のところにサインをしてください)
・Can you please give me your signature here? (ここにあなたのサインをお願いできますか)
・A signature collection campaign is not easy to accomplish.(署名運動は簡単に達成できるものではない)
・The two companies have reached an agreement shortly to be formalized by the signature of the president. (両社は間もなく合意に達し、社長の署名によって正式に決定される予定だ)
・Some merchants require that every transaction over a certain amount be verified by signature.( 一部の加盟店では、一定額以上の取引はすべて署名で確認することを義務付けている)
・The band blends jazz with classic and world music to create a signature sound.(このバンドは、ジャズとクラシック音楽、ワールド ミュージックを融合させて独自のサウンドを生み出している)
・The signature food of the cafe is the "vegetable potage soup", made with local organic vegetables.(カフェの看板メニューは、地元の有機野菜を使った「野菜のポタージュスープ」だ)
・This is their signature item. (これがこのお店の名物だ)
・The time signature tells us how to count the rhythms. (拍子記号はリズムの数え方を教えてくれる)
・I affixed my signature to each of the documents.(各書類に署名をした)
シグネチャー【signature】
シグネチャ [signature]
シグネチャ
【英】signature
シグネチャとは、電子メールなどのメッセージの末尾に付加されるメッセージや個人情報のことである。
シグネチャは、メールソフトの機能として提供されていることが多く、あらかじめ記述する内容を設定しておくことで、送信メールにかならずシグネチャが付加されるようになる。なお、データやメッセージの正当性を補償する電子署名とは別のものである。
シグネチャの用途としては、例えばビジネスでは、送信者の会社の連絡先や部署、氏名などを記すのが一般的であるが、プライベートで用いる場合は、送信者のメッセージなどが記されていることもある。
Signature クラス
アセンブリ: System.Security (system.security.dll 内)


Signature クラスは、XML デジタル署名仕様に定義されている XML 署名の <Signature> 要素を表します。<Signature> 要素は、XML デジタル署名のルート要素です。SignedInfo、SignatureValue、KeyInfo、および ObjectList プロパティは、<Signature> 要素のサブ要素をカプセル化します。
<Signature> 要素の詳細については、www.w3.org/TR/xmldsig-core/ の W3C 仕様を参照してください。

Signature クラスを SignedXml クラスと共に使用し、エンベロープ シグネチャで XML ドキュメントの署名および検証を行うコードの例を次に示します。
' This example signs an XML file using an ' envelope signature. It then verifies the ' signed XML. ' Imports System Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.Text Imports System.Xml Module SignVerifyEnvelope Sub Main(ByVal args() As String) ' Generate a signing key. Dim Key As New RSACryptoServiceProvider() Try ' Sign an XML file and save the signature to a ' new file. SignXmlFile("Test.xml", "SignedExample.xml", Key) Console.WriteLine("XML file signed.") ' Verify the signature of the signed XML. Console.WriteLine("Verifying signature...") Dim result As Boolean = VerifyXmlFile("SignedExample.xml") ' Display the results of the signature verification to ' the console. If result Then Console.WriteLine("The XML signature is valid.") Else Console.WriteLine("The XML signature is not valid.") End If Catch e As CryptographicException Console.WriteLine(e.Message) Finally ' Clear resources associated with the ' RSACryptoServiceProvider. Key.Clear() End Try End Sub ' Sign an XML file and save the signature in a new file. Sub SignXmlFile(ByVal FileName As String, ByVal SignedFileName As String, ByVal Key As RSA) ' Check the arguments. If FileName Is Nothing Then Throw New ArgumentNullException("FileName") End If If SignedFileName Is Nothing Then Throw New ArgumentNullException("SignedFileName") End If If Key Is Nothing Then Throw New ArgumentNullException("Key") End If ' Create a new XML document. Dim doc As New XmlDocument() ' Format the document to ignore white spaces. doc.PreserveWhitespace = False ' Load the passed XML file using it's name. doc.Load(New XmlTextReader(FileName)) ' Create a SignedXml object. Dim signedXml As New SignedXml(doc) ' Add the key to the SignedXml document. signedXml.SigningKey = Key ' Get the signature object from the SignedXml object. Dim XMLSignature As Signature = signedXml.Signature ' Create a reference to be signed. Pass "" ' to specify that all of the current XML ' document should be signed. Dim reference As New Reference("") ' Add an enveloped transformation to the reference. Dim env As New XmlDsigEnvelopedSignatureTransform() reference.AddTransform(env) ' Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference) ' Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). Dim keyInfo As New KeyInfo() keyInfo.AddClause(New RSAKeyValue(CType(Key, RSA))) ' Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo ' Compute the signature. signedXml.ComputeSignature() ' Get the XML representation of the signature and save ' it to an XmlElement object. Dim xmlDigitalSignature As XmlElement = signedXml.GetXml() ' Append the element to the XML document. doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, True)) If TypeOf doc.FirstChild Is XmlDeclaration Then doc.RemoveChild(doc.FirstChild) End If ' Save the signed XML document to a file specified ' using the passed string. Dim xmltw As New XmlTextWriter(SignedFileName, New UTF8Encoding(False)) doc.WriteTo(xmltw) xmltw.Close() End Sub ' Verify the signature of an XML file and return the result. Function VerifyXmlFile(ByVal Name As String) As [Boolean] ' Check the arguments. If Name Is Nothing Then Throw New ArgumentNullException("Name") End If ' Create a new XML document. Dim xmlDocument As New XmlDocument() ' Format using white spaces. xmlDocument.PreserveWhitespace = True ' Load the passed XML file into the document. xmlDocument.Load(Name) ' Create a new SignedXml object and pass it ' the XML document class. Dim signedXml As New SignedXml(xmlDocument) ' Find the "Signature" node and create a new ' XmlNodeList object. Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature") ' Load the signature node. signedXml.LoadXml(CType(nodeList(0), XmlElement)) ' Check the signature and return the result. Return signedXml.CheckSignature() End Function End Module
// // This example signs an XML file using an // envelope signature. It then verifies the // signed XML. // using System; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.Text; using System.Xml; public class SignVerifyEnvelope { public static void Main(String[] args) { // Generate a signing key. RSACryptoServiceProvider Key = new RSACryptoServiceProvider(); try { // Sign an XML file and save the signature to a // new file. SignXmlFile("Test.xml", "SignedExample.xml", Key); Console.WriteLine("XML file signed."); // Verify the signature of the signed XML. Console.WriteLine("Verifying signature..."); bool result = VerifyXmlFile("SignedExample.xml"); // Display the results of the signature verification to // the console. if (result) { Console.WriteLine("The XML signature is valid."); } else { Console.WriteLine("The XML signature is not valid."); } } catch (CryptographicException e) { Console.WriteLine(e.Message); } finally { // Clear resources associated with the // RSACryptoServiceProvider. Key.Clear(); } } // Sign an XML file and save the signature in a new file. public static void SignXmlFile(string FileName, string SignedFileName, RSA Key) { // Check the arguments. if (FileName == null) throw new ArgumentNullException("FileName"); if (SignedFileName == null) throw new ArgumentNullException("SignedFileName"); if (Key == null) throw new ArgumentNullException("Key"); // Create a new XML document. XmlDocument doc = new XmlDocument(); // Format the document to ignore white spaces. doc.PreserveWhitespace = false; // Load the passed XML file using it's name. doc.Load(new XmlTextReader(FileName)); // Create a SignedXml object. SignedXml signedXml = new SignedXml(doc); // Add the key to the SignedXml document. signedXml.SigningKey = Key; // Get the signature object from the SignedXml object. Signature XMLSignature = signedXml.Signature; // Create a reference to be signed. Pass "" // to specify that all of the current XML // document should be signed. Reference reference = new Reference(""); // Add an enveloped transformation to the reference. XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform(); reference.AddTransform(env); // Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue((RSA)Key)); // Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo; // 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(xmlDigitalSignature, true)); if (doc.FirstChild is XmlDeclaration) { doc.RemoveChild(doc.FirstChild); } // Save the signed XML document to a file specified // using the passed string. XmlTextWriter xmltw = new XmlTextWriter(SignedFileName, new UTF8Encoding(false)); doc.WriteTo(xmltw); xmltw.Close(); } // Verify the signature of an XML file and return the result. public static Boolean VerifyXmlFile(String Name) { // Check the arguments. if (Name == null) throw new ArgumentNullException("Name"); // Create a new XML document. XmlDocument xmlDocument = new XmlDocument(); // Format using white spaces. xmlDocument.PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument.Load(Name); // Create a new SignedXml object and pass it // the XML document class. SignedXml signedXml = new SignedXml(xmlDocument); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature"); // Load the signature node. signedXml.LoadXml((XmlElement)nodeList[0]); // Check the signature and return the result. return signedXml.CheckSignature(); } }
// // This example signs an XML file using an // envelope signature. It then verifies the // signed XML. // #using <System.Xml.dll> #using <System.Security.dll> #using <System.dll> using namespace System; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::Text; using namespace System::Xml; // Sign an XML file and save the signature in a new file. static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) { // Check the arguments. if ( FileName == nullptr ) throw gcnew ArgumentNullException( L"FileName" ); if ( SignedFileName == nullptr ) throw gcnew ArgumentNullException( L"SignedFileName" ); if ( Key == nullptr ) throw gcnew ArgumentNullException( L"Key" ); // Create a new XML document. XmlDocument^ doc = gcnew XmlDocument; // Format the document to ignore white spaces. doc->PreserveWhitespace = false; // Load the passed XML file using it's name. doc->Load( gcnew XmlTextReader( FileName ) ); // Create a SignedXml object. SignedXml^ signedXml = gcnew SignedXml( doc ); // Add the key to the SignedXml document. signedXml->SigningKey = Key; // Get the signature object from the SignedXml object. Signature^ XMLSignature = signedXml->Signature; // Create a reference to be signed. Pass "" // to specify that all of the current XML // document should be signed. Reference^ reference = gcnew Reference( L"" ); // Add an enveloped transformation to the reference. XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; reference->AddTransform( env ); // Add the Reference object to the Signature object. XMLSignature->SignedInfo->AddReference( reference ); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo^ keyInfo = gcnew KeyInfo; keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast<RSA^>(Key) ) ); // Add the KeyInfo object to the Reference object. XMLSignature->KeyInfo = keyInfo; // 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( xmlDigitalSignature, true ) ); if ( dynamic_cast<XmlDeclaration^>(doc->FirstChild) ) { doc->RemoveChild( doc->FirstChild ); } // Save the signed XML document to a file specified // using the passed string. XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); doc->WriteTo( xmltw ); xmltw->Close(); } // Verify the signature of an XML file and return the result. static Boolean VerifyXmlFile( String^ Name ) { // Check the arguments. if ( Name == nullptr ) throw gcnew ArgumentNullException( L"Name" ); // Create a new XML document. XmlDocument^ xmlDocument = gcnew XmlDocument; // Format using white spaces. xmlDocument->PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument->Load( Name ); // Create a new SignedXml object and pass it // the XML document class. SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); // Load the signature node. signedXml->LoadXml( dynamic_cast<XmlElement^>(nodeList->Item( 0 )) ); // Check the signature and return the result. return signedXml->CheckSignature(); } int main() { // Generate a signing key. RSACryptoServiceProvider^ Key = gcnew RSACryptoServiceProvider; try { // Sign an XML file and save the signature to a // new file. SignXmlFile( L"Test.xml", L"SignedExample.xml", Key ); Console::WriteLine( L"XML file signed." ); // Verify the signature of the signed XML. Console::WriteLine( L"Verifying signature..." ); bool result = VerifyXmlFile( L"SignedExample.xml" ); // Display the results of the signature verification to // the console. if ( result ) { Console::WriteLine( L"The XML signature is valid." ); } else { Console::WriteLine( L"The XML signature is not valid." ); } } catch ( CryptographicException^ e ) { Console::WriteLine( e->Message ); } finally { // Clear resources associated with the // RSACryptoServiceProvider. Key->Clear(); } return 1; }
Signature クラスを SignedXml クラスと共に使用し、デタッチ シグネチャで XML ドキュメントの署名および検証を行うコードの例を次に示します。
' This example signs a URL using an ' envelope signature. It then verifies the ' signed XML. ' Imports System Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.Text Imports System.Xml Module SignVerifyEnvelope Sub Main(ByVal args() As String) ' Generate a signing key. Dim Key As New RSACryptoServiceProvider() Try ' Sign the detached resource and save the signature in an XML file. SignDetachedResource("http://www.microsoft.com", "SignedExample.xml", Key) Console.WriteLine("XML file signed.") ' Verify the signature of the signed XML. Console.WriteLine("Verifying signature...") Dim result As Boolean = VerifyXmlFile("SignedExample.xml") ' Display the results of the signature verification to \ ' the console. If result Then Console.WriteLine("The XML signature is valid.") Else Console.WriteLine("The XML signature is not valid.") End If Catch e As CryptographicException Console.WriteLine(e.Message) Finally ' Clear resources associated with the ' RSACryptoServiceProvider. Key.Clear() End Try End Sub ' Sign an XML file and save the signature in a new file. Sub SignDetachedResource(ByVal URIString As String, ByVal XmlSigFileName As String, ByVal Key As RSA) ' Check the arguments. If URIString Is Nothing Then Throw New ArgumentNullException("URIString") End If If XmlSigFileName Is Nothing Then Throw New ArgumentNullException("XmlSigFileName") End If If Key Is Nothing Then Throw New ArgumentNullException("Key") End If ' Create a SignedXml object. Dim signedXml As New SignedXml() ' Assign the key to the SignedXml object. signedXml.SigningKey = Key ' Get the signature object from the SignedXml object. Dim XMLSignature As Signature = signedXml.Signature ' Create a reference to be signed. Dim reference As New Reference() ' Add the passed URI to the reference object. reference.Uri = URIString ' Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference) ' Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). Dim keyInfo As New KeyInfo() keyInfo.AddClause(New RSAKeyValue(CType(Key, RSA))) ' Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo ' Compute the signature. signedXml.ComputeSignature() ' Get the XML representation of the signature and save ' it to an XmlElement object. Dim xmlDigitalSignature As XmlElement = signedXml.GetXml() ' Save the signed XML document to a file specified ' using the passed string. Dim xmltw As New XmlTextWriter(XmlSigFileName, New UTF8Encoding(False)) xmlDigitalSignature.WriteTo(xmltw) xmltw.Close() End Sub ' Verify the signature of an XML file and return the result. Function VerifyXmlFile(ByVal Name As String) As [Boolean] ' Check the arguments. If Name Is Nothing Then Throw New ArgumentNullException("Name") End If ' Create a new XML document. Dim xmlDocument As New XmlDocument() ' Format using white spaces. xmlDocument.PreserveWhitespace = True ' Load the passed XML file into the document. xmlDocument.Load(Name) ' Create a new SignedXml object and pass it ' the XML document class. Dim signedXml As New SignedXml(xmlDocument) ' Find the "Signature" node and create a new ' XmlNodeList object. Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature") ' Load the signature node. signedXml.LoadXml(CType(nodeList(0), XmlElement)) ' Check the signature and return the result. Return signedXml.CheckSignature() End Function End Module
// // This example signs a URL using an // envelope signature. It then verifies the // signed XML. // using System; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.Text; using System.Xml; public class SignVerifyEnvelope { public static void Main(String[] args) { // Generate a signing key. RSACryptoServiceProvider Key = new RSACryptoServiceProvider(); try { // Sign the detached resource and save the signature in an XML file. SignDetachedResource("http://www.microsoft.com", "SignedExample.xml", Key); Console.WriteLine("XML file signed."); // Verify the signature of the signed XML. Console.WriteLine("Verifying signature..."); bool result = VerifyXmlFile("SignedExample.xml"); // Display the results of the signature verification to \ // the console. if (result) { Console.WriteLine("The XML signature is valid."); } else { Console.WriteLine("The XML signature is not valid."); } } catch (CryptographicException e) { Console.WriteLine(e.Message); } finally { // Clear resources associated with the // RSACryptoServiceProvider. Key.Clear(); } } // Sign an XML file and save the signature in a new file. public static void SignDetachedResource(string URIString, string XmlSigFileName, RSA Key) { // Check the arguments. if (URIString == null) throw new ArgumentNullException("URIString"); if (XmlSigFileName == null) throw new ArgumentNullException("XmlSigFileName"); if (Key == null) throw new ArgumentNullException("Key"); // Create a SignedXml object. SignedXml signedXml = new SignedXml(); // Assign the key to the SignedXml object. signedXml.SigningKey = Key; // Get the signature object from the SignedXml object. Signature XMLSignature = signedXml.Signature; // Create a reference to be signed. Reference reference = new Reference(); // Add the passed URI to the reference object. reference.Uri = URIString; // Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue((RSA)Key)); // Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo; // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature and save // it to an XmlElement object. XmlElement xmlDigitalSignature = signedXml.GetXml(); // Save the signed XML document to a file specified // using the passed string. XmlTextWriter xmltw = new XmlTextWriter(XmlSigFileName, new UTF8Encoding(false)); xmlDigitalSignature.WriteTo(xmltw); xmltw.Close(); } // Verify the signature of an XML file and return the result. public static Boolean VerifyXmlFile(String Name) { // Check the arguments. if (Name == null) throw new ArgumentNullException("Name"); // Create a new XML document. XmlDocument xmlDocument = new XmlDocument(); // Format using white spaces. xmlDocument.PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument.Load(Name); // Create a new SignedXml object and pass it // the XML document class. SignedXml signedXml = new SignedXml(xmlDocument); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature"); // Load the signature node. signedXml.LoadXml((XmlElement)nodeList[0]); // Check the signature and return the result. return signedXml.CheckSignature(); } }
// // This example signs a URL using an // envelope signature. It then verifies the // signed XML. // #using <System.dll> #using <System.Xml.dll> #using <System.Security.dll> using namespace System; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::Text; using namespace System::Xml; namespace Sample { public ref class SignVerifyEnvelope { public: static void Work() { // Generate a signing key. RSACryptoServiceProvider^ key = gcnew RSACryptoServiceProvider(); try { // Sign the detached resource and save the // signature in an XML file. SignDetachedResource("http://www.microsoft.com" , "SignedExample.xml", key); Console::WriteLine("XML file signed."); // Verify the signature of the signed XML. Console::WriteLine("Verifying signature..."); bool result = VerifyXmlFile("SignedExample.xml"); // Display the results of the signature verification // to the console. if (result) { Console::WriteLine("The XML signature" " is valid."); } else { Console::WriteLine("The XML signature" " is not valid."); } Console::ReadLine(); } catch (CryptographicException^ ex) { Console::WriteLine(ex->Message); } finally { // Clear resources associated with the // RSACryptoServiceProvider. key->Clear(); } } // Sign an XML file and save the signature in a new file. static void SignDetachedResource(String^ uri, String^ xmlFileName, RSA^ key) { // Check the arguments. if (uri->Length == 0) { throw gcnew ArgumentException("uri"); } if (xmlFileName->Length == 0) { throw gcnew ArgumentException("xmlFileName"); } if (key->KeySize == 0) { throw gcnew ArgumentException("key"); } // Create a SignedXml object. SignedXml^ signedXml = gcnew SignedXml(); // Assign the key to the SignedXml object. signedXml->SigningKey = key; // Get the signature object from the SignedXml object. Signature^ xmlSignature = signedXml->Signature; // Create a reference to be signed. Reference^ reference = gcnew Reference(); // Add the passed URI to the reference object. reference->Uri = uri; // Add the Reference object to the Signature object. xmlSignature->SignedInfo->AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient // find key to validate). KeyInfo^ keyInfo = gcnew KeyInfo(); keyInfo->AddClause( gcnew RSAKeyValue(key)); // Add the KeyInfo object to the Reference object. xmlSignature->KeyInfo = keyInfo; // Compute the signature. signedXml->ComputeSignature(); // Get the XML representation of the signature and save // it to an XmlElement object. XmlElement^ xmlDigitalSignature = signedXml->GetXml(); // Save the signed XML document to a file specified // using the passed string. XmlTextWriter^ xmlTextWriter = gcnew XmlTextWriter( xmlFileName, gcnew UTF8Encoding(false)); xmlDigitalSignature->WriteTo(xmlTextWriter); xmlTextWriter->Close(); } // Verify the signature of an XML file and return the result. static Boolean VerifyXmlFile(String^ documentName) { // Check the arguments. if (documentName->Length == 0) { throw gcnew ArgumentException("documentName"); } // Create a new XML document. XmlDocument^ xmlDocument = gcnew XmlDocument(); // Format using white spaces. xmlDocument->PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument->Load(documentName); // Create a new SignedXml object and pass it // the XML document class. SignedXml^ signedXml = gcnew SignedXml(xmlDocument); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName("Signature"); // Load the signature node. signedXml->LoadXml( (XmlElement^) nodeList->Item(0)); // Check the signature and return the result. return signedXml->CheckSignature(); } }; } int main() { Sample::SignVerifyEnvelope::Work(); }

System.Security.Cryptography.Xml.Signature


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Signature コンストラクタ
アセンブリ: System.Security (system.security.dll 内)


Signature クラスを SignedXml クラスと共に使用し、エンベロープ シグネチャで XML ドキュメントの署名および検証を行うコードの例を次に示します。
' This example signs an XML file using an ' envelope signature. It then verifies the ' signed XML. ' Imports System Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.Text Imports System.Xml Module SignVerifyEnvelope Sub Main(ByVal args() As String) ' Generate a signing key. Dim Key As New RSACryptoServiceProvider() Try ' Sign an XML file and save the signature to a ' new file. SignXmlFile("Test.xml", "SignedExample.xml", Key) Console.WriteLine("XML file signed.") ' Verify the signature of the signed XML. Console.WriteLine("Verifying signature...") Dim result As Boolean = VerifyXmlFile("SignedExample.xml") ' Display the results of the signature verification to ' the console. If result Then Console.WriteLine("The XML signature is valid.") Else Console.WriteLine("The XML signature is not valid.") End If Catch e As CryptographicException Console.WriteLine(e.Message) Finally ' Clear resources associated with the ' RSACryptoServiceProvider. Key.Clear() End Try End Sub ' Sign an XML file and save the signature in a new file. Sub SignXmlFile(ByVal FileName As String, ByVal SignedFileName As String, ByVal Key As RSA) ' Check the arguments. If FileName Is Nothing Then Throw New ArgumentNullException("FileName") End If If SignedFileName Is Nothing Then Throw New ArgumentNullException("SignedFileName") End If If Key Is Nothing Then Throw New ArgumentNullException("Key") End If ' Create a new XML document. Dim doc As New XmlDocument() ' Format the document to ignore white spaces. doc.PreserveWhitespace = False ' Load the passed XML file using it's name. doc.Load(New XmlTextReader(FileName)) ' Create a SignedXml object. Dim signedXml As New SignedXml(doc) ' Add the key to the SignedXml document. signedXml.SigningKey = Key ' Get the signature object from the SignedXml object. Dim XMLSignature As Signature = signedXml.Signature ' Create a reference to be signed. Pass "" ' to specify that all of the current XML ' document should be signed. Dim reference As New Reference("") ' Add an enveloped transformation to the reference. Dim env As New XmlDsigEnvelopedSignatureTransform() reference.AddTransform(env) ' Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference) ' Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). Dim keyInfo As New KeyInfo() keyInfo.AddClause(New RSAKeyValue(CType(Key, RSA))) ' Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo ' Compute the signature. signedXml.ComputeSignature() ' Get the XML representation of the signature and save ' it to an XmlElement object. Dim xmlDigitalSignature As XmlElement = signedXml.GetXml() ' Append the element to the XML document. doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, True)) If TypeOf doc.FirstChild Is XmlDeclaration Then doc.RemoveChild(doc.FirstChild) End If ' Save the signed XML document to a file specified ' using the passed string. Dim xmltw As New XmlTextWriter(SignedFileName, New UTF8Encoding(False)) doc.WriteTo(xmltw) xmltw.Close() End Sub ' Verify the signature of an XML file and return the result. Function VerifyXmlFile(ByVal Name As String) As [Boolean] ' Check the arguments. If Name Is Nothing Then Throw New ArgumentNullException("Name") End If ' Create a new XML document. Dim xmlDocument As New XmlDocument() ' Format using white spaces. xmlDocument.PreserveWhitespace = True ' Load the passed XML file into the document. xmlDocument.Load(Name) ' Create a new SignedXml object and pass it ' the XML document class. Dim signedXml As New SignedXml(xmlDocument) ' Find the "Signature" node and create a new ' XmlNodeList object. Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature") ' Load the signature node. signedXml.LoadXml(CType(nodeList(0), XmlElement)) ' Check the signature and return the result. Return signedXml.CheckSignature() End Function End Module
// // This example signs an XML file using an // envelope signature. It then verifies the // signed XML. // using System; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.Text; using System.Xml; public class SignVerifyEnvelope { public static void Main(String[] args) { // Generate a signing key. RSACryptoServiceProvider Key = new RSACryptoServiceProvider(); try { // Sign an XML file and save the signature to a // new file. SignXmlFile("Test.xml", "SignedExample.xml", Key); Console.WriteLine("XML file signed."); // Verify the signature of the signed XML. Console.WriteLine("Verifying signature..."); bool result = VerifyXmlFile("SignedExample.xml"); // Display the results of the signature verification to // the console. if (result) { Console.WriteLine("The XML signature is valid."); } else { Console.WriteLine("The XML signature is not valid."); } } catch (CryptographicException e) { Console.WriteLine(e.Message); } finally { // Clear resources associated with the // RSACryptoServiceProvider. Key.Clear(); } } // Sign an XML file and save the signature in a new file. public static void SignXmlFile(string FileName, string SignedFileName, RSA Key) { // Check the arguments. if (FileName == null) throw new ArgumentNullException("FileName"); if (SignedFileName == null) throw new ArgumentNullException("SignedFileName"); if (Key == null) throw new ArgumentNullException("Key"); // Create a new XML document. XmlDocument doc = new XmlDocument(); // Format the document to ignore white spaces. doc.PreserveWhitespace = false; // Load the passed XML file using it's name. doc.Load(new XmlTextReader(FileName)); // Create a SignedXml object. SignedXml signedXml = new SignedXml(doc); // Add the key to the SignedXml document. signedXml.SigningKey = Key; // Get the signature object from the SignedXml object. Signature XMLSignature = signedXml.Signature; // Create a reference to be signed. Pass "" // to specify that all of the current XML // document should be signed. Reference reference = new Reference(""); // Add an enveloped transformation to the reference. XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform(); reference.AddTransform(env); // Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue((RSA)Key)); // Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo; // 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(xmlDigitalSignature, true)); if (doc.FirstChild is XmlDeclaration) { doc.RemoveChild(doc.FirstChild); } // Save the signed XML document to a file specified // using the passed string. XmlTextWriter xmltw = new XmlTextWriter(SignedFileName, new UTF8Encoding(false)); doc.WriteTo(xmltw); xmltw.Close(); } // Verify the signature of an XML file and return the result. public static Boolean VerifyXmlFile(String Name) { // Check the arguments. if (Name == null) throw new ArgumentNullException("Name"); // Create a new XML document. XmlDocument xmlDocument = new XmlDocument(); // Format using white spaces. xmlDocument.PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument.Load(Name); // Create a new SignedXml object and pass it // the XML document class. SignedXml signedXml = new SignedXml(xmlDocument); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature"); // Load the signature node. signedXml.LoadXml((XmlElement)nodeList[0]); // Check the signature and return the result. return signedXml.CheckSignature(); } }
// // This example signs an XML file using an // envelope signature. It then verifies the // signed XML. // #using <System.Xml.dll> #using <System.Security.dll> #using <System.dll> using namespace System; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::Text; using namespace System::Xml; // Sign an XML file and save the signature in a new file. static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) { // Check the arguments. if ( FileName == nullptr ) throw gcnew ArgumentNullException( L"FileName" ); if ( SignedFileName == nullptr ) throw gcnew ArgumentNullException( L"SignedFileName" ); if ( Key == nullptr ) throw gcnew ArgumentNullException( L"Key" ); // Create a new XML document. XmlDocument^ doc = gcnew XmlDocument; // Format the document to ignore white spaces. doc->PreserveWhitespace = false; // Load the passed XML file using it's name. doc->Load( gcnew XmlTextReader( FileName ) ); // Create a SignedXml object. SignedXml^ signedXml = gcnew SignedXml( doc ); // Add the key to the SignedXml document. signedXml->SigningKey = Key; // Get the signature object from the SignedXml object. Signature^ XMLSignature = signedXml->Signature; // Create a reference to be signed. Pass "" // to specify that all of the current XML // document should be signed. Reference^ reference = gcnew Reference( L"" ); // Add an enveloped transformation to the reference. XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; reference->AddTransform( env ); // Add the Reference object to the Signature object. XMLSignature->SignedInfo->AddReference( reference ); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo^ keyInfo = gcnew KeyInfo; keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast<RSA^>(Key) ) ); // Add the KeyInfo object to the Reference object. XMLSignature->KeyInfo = keyInfo; // 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( xmlDigitalSignature, true ) ); if ( dynamic_cast<XmlDeclaration^>(doc->FirstChild) ) { doc->RemoveChild( doc->FirstChild ); } // Save the signed XML document to a file specified // using the passed string. XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); doc->WriteTo( xmltw ); xmltw->Close(); } // Verify the signature of an XML file and return the result. static Boolean VerifyXmlFile( String^ Name ) { // Check the arguments. if ( Name == nullptr ) throw gcnew ArgumentNullException( L"Name" ); // Create a new XML document. XmlDocument^ xmlDocument = gcnew XmlDocument; // Format using white spaces. xmlDocument->PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument->Load( Name ); // Create a new SignedXml object and pass it // the XML document class. SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); // Load the signature node. signedXml->LoadXml( dynamic_cast<XmlElement^>(nodeList->Item( 0 )) ); // Check the signature and return the result. return signedXml->CheckSignature(); } int main() { // Generate a signing key. RSACryptoServiceProvider^ Key = gcnew RSACryptoServiceProvider; try { // Sign an XML file and save the signature to a // new file. SignXmlFile( L"Test.xml", L"SignedExample.xml", Key ); Console::WriteLine( L"XML file signed." ); // Verify the signature of the signed XML. Console::WriteLine( L"Verifying signature..." ); bool result = VerifyXmlFile( L"SignedExample.xml" ); // Display the results of the signature verification to // the console. if ( result ) { Console::WriteLine( L"The XML signature is valid." ); } else { Console::WriteLine( L"The XML signature is not valid." ); } } catch ( CryptographicException^ e ) { Console::WriteLine( e->Message ); } finally { // Clear resources associated with the // RSACryptoServiceProvider. Key->Clear(); } return 1; }
Signature クラスを SignedXml クラスと共に使用し、デタッチ シグネチャで XML ドキュメントの署名および検証を行うコードの例を次に示します。
' This example signs a URL using an ' envelope signature. It then verifies the ' signed XML. ' Imports System Imports System.Security.Cryptography Imports System.Security.Cryptography.Xml Imports System.Text Imports System.Xml Module SignVerifyEnvelope Sub Main(ByVal args() As String) ' Generate a signing key. Dim Key As New RSACryptoServiceProvider() Try ' Sign the detached resource and save the signature in an XML file. SignDetachedResource("http://www.microsoft.com", "SignedExample.xml", Key) Console.WriteLine("XML file signed.") ' Verify the signature of the signed XML. Console.WriteLine("Verifying signature...") Dim result As Boolean = VerifyXmlFile("SignedExample.xml") ' Display the results of the signature verification to \ ' the console. If result Then Console.WriteLine("The XML signature is valid.") Else Console.WriteLine("The XML signature is not valid.") End If Catch e As CryptographicException Console.WriteLine(e.Message) Finally ' Clear resources associated with the ' RSACryptoServiceProvider. Key.Clear() End Try End Sub ' Sign an XML file and save the signature in a new file. Sub SignDetachedResource(ByVal URIString As String, ByVal XmlSigFileName As String, ByVal Key As RSA) ' Check the arguments. If URIString Is Nothing Then Throw New ArgumentNullException("URIString") End If If XmlSigFileName Is Nothing Then Throw New ArgumentNullException("XmlSigFileName") End If If Key Is Nothing Then Throw New ArgumentNullException("Key") End If ' Create a SignedXml object. Dim signedXml As New SignedXml() ' Assign the key to the SignedXml object. signedXml.SigningKey = Key ' Get the signature object from the SignedXml object. Dim XMLSignature As Signature = signedXml.Signature ' Create a reference to be signed. Dim reference As New Reference() ' Add the passed URI to the reference object. reference.Uri = URIString ' Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference) ' Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). Dim keyInfo As New KeyInfo() keyInfo.AddClause(New RSAKeyValue(CType(Key, RSA))) ' Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo ' Compute the signature. signedXml.ComputeSignature() ' Get the XML representation of the signature and save ' it to an XmlElement object. Dim xmlDigitalSignature As XmlElement = signedXml.GetXml() ' Save the signed XML document to a file specified ' using the passed string. Dim xmltw As New XmlTextWriter(XmlSigFileName, New UTF8Encoding(False)) xmlDigitalSignature.WriteTo(xmltw) xmltw.Close() End Sub ' Verify the signature of an XML file and return the result. Function VerifyXmlFile(ByVal Name As String) As [Boolean] ' Check the arguments. If Name Is Nothing Then Throw New ArgumentNullException("Name") End If ' Create a new XML document. Dim xmlDocument As New XmlDocument() ' Format using white spaces. xmlDocument.PreserveWhitespace = True ' Load the passed XML file into the document. xmlDocument.Load(Name) ' Create a new SignedXml object and pass it ' the XML document class. Dim signedXml As New SignedXml(xmlDocument) ' Find the "Signature" node and create a new ' XmlNodeList object. Dim nodeList As XmlNodeList = xmlDocument.GetElementsByTagName("Signature") ' Load the signature node. signedXml.LoadXml(CType(nodeList(0), XmlElement)) ' Check the signature and return the result. Return signedXml.CheckSignature() End Function End Module
// // This example signs a URL using an // envelope signature. It then verifies the // signed XML. // using System; using System.Security.Cryptography; using System.Security.Cryptography.Xml; using System.Text; using System.Xml; public class SignVerifyEnvelope { public static void Main(String[] args) { // Generate a signing key. RSACryptoServiceProvider Key = new RSACryptoServiceProvider(); try { // Sign the detached resource and save the signature in an XML file. SignDetachedResource("http://www.microsoft.com", "SignedExample.xml", Key); Console.WriteLine("XML file signed."); // Verify the signature of the signed XML. Console.WriteLine("Verifying signature..."); bool result = VerifyXmlFile("SignedExample.xml"); // Display the results of the signature verification to \ // the console. if (result) { Console.WriteLine("The XML signature is valid."); } else { Console.WriteLine("The XML signature is not valid."); } } catch (CryptographicException e) { Console.WriteLine(e.Message); } finally { // Clear resources associated with the // RSACryptoServiceProvider. Key.Clear(); } } // Sign an XML file and save the signature in a new file. public static void SignDetachedResource(string URIString, string XmlSigFileName, RSA Key) { // Check the arguments. if (URIString == null) throw new ArgumentNullException("URIString"); if (XmlSigFileName == null) throw new ArgumentNullException("XmlSigFileName"); if (Key == null) throw new ArgumentNullException("Key"); // Create a SignedXml object. SignedXml signedXml = new SignedXml(); // Assign the key to the SignedXml object. signedXml.SigningKey = Key; // Get the signature object from the SignedXml object. Signature XMLSignature = signedXml.Signature; // Create a reference to be signed. Reference reference = new Reference(); // Add the passed URI to the reference object. reference.Uri = URIString; // Add the Reference object to the Signature object. XMLSignature.SignedInfo.AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). KeyInfo keyInfo = new KeyInfo(); keyInfo.AddClause(new RSAKeyValue((RSA)Key)); // Add the KeyInfo object to the Reference object. XMLSignature.KeyInfo = keyInfo; // Compute the signature. signedXml.ComputeSignature(); // Get the XML representation of the signature and save // it to an XmlElement object. XmlElement xmlDigitalSignature = signedXml.GetXml(); // Save the signed XML document to a file specified // using the passed string. XmlTextWriter xmltw = new XmlTextWriter(XmlSigFileName, new UTF8Encoding(false)); xmlDigitalSignature.WriteTo(xmltw); xmltw.Close(); } // Verify the signature of an XML file and return the result. public static Boolean VerifyXmlFile(String Name) { // Check the arguments. if (Name == null) throw new ArgumentNullException("Name"); // Create a new XML document. XmlDocument xmlDocument = new XmlDocument(); // Format using white spaces. xmlDocument.PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument.Load(Name); // Create a new SignedXml object and pass it // the XML document class. SignedXml signedXml = new SignedXml(xmlDocument); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList nodeList = xmlDocument.GetElementsByTagName("Signature"); // Load the signature node. signedXml.LoadXml((XmlElement)nodeList[0]); // Check the signature and return the result. return signedXml.CheckSignature(); } }
// // This example signs a URL using an // envelope signature. It then verifies the // signed XML. // #using <System.dll> #using <System.Xml.dll> #using <System.Security.dll> using namespace System; using namespace System::Security::Cryptography; using namespace System::Security::Cryptography::Xml; using namespace System::Text; using namespace System::Xml; namespace Sample { public ref class SignVerifyEnvelope { public: static void Work() { // Generate a signing key. RSACryptoServiceProvider^ key = gcnew RSACryptoServiceProvider(); try { // Sign the detached resource and save the // signature in an XML file. SignDetachedResource("http://www.microsoft.com" , "SignedExample.xml", key); Console::WriteLine("XML file signed."); // Verify the signature of the signed XML. Console::WriteLine("Verifying signature..."); bool result = VerifyXmlFile("SignedExample.xml"); // Display the results of the signature verification // to the console. if (result) { Console::WriteLine("The XML signature" " is valid."); } else { Console::WriteLine("The XML signature" " is not valid."); } Console::ReadLine(); } catch (CryptographicException^ ex) { Console::WriteLine(ex->Message); } finally { // Clear resources associated with the // RSACryptoServiceProvider. key->Clear(); } } // Sign an XML file and save the signature in a new file. static void SignDetachedResource(String^ uri, String^ xmlFileName, RSA^ key) { // Check the arguments. if (uri->Length == 0) { throw gcnew ArgumentException("uri"); } if (xmlFileName->Length == 0) { throw gcnew ArgumentException("xmlFileName"); } if (key->KeySize == 0) { throw gcnew ArgumentException("key"); } // Create a SignedXml object. SignedXml^ signedXml = gcnew SignedXml(); // Assign the key to the SignedXml object. signedXml->SigningKey = key; // Get the signature object from the SignedXml object. Signature^ xmlSignature = signedXml->Signature; // Create a reference to be signed. Reference^ reference = gcnew Reference(); // Add the passed URI to the reference object. reference->Uri = uri; // Add the Reference object to the Signature object. xmlSignature->SignedInfo->AddReference(reference); // Add an RSAKeyValue KeyInfo (optional; helps recipient // find key to validate). KeyInfo^ keyInfo = gcnew KeyInfo(); keyInfo->AddClause( gcnew RSAKeyValue(key)); // Add the KeyInfo object to the Reference object. xmlSignature->KeyInfo = keyInfo; // Compute the signature. signedXml->ComputeSignature(); // Get the XML representation of the signature and save // it to an XmlElement object. XmlElement^ xmlDigitalSignature = signedXml->GetXml(); // Save the signed XML document to a file specified // using the passed string. XmlTextWriter^ xmlTextWriter = gcnew XmlTextWriter( xmlFileName, gcnew UTF8Encoding(false)); xmlDigitalSignature->WriteTo(xmlTextWriter); xmlTextWriter->Close(); } // Verify the signature of an XML file and return the result. static Boolean VerifyXmlFile(String^ documentName) { // Check the arguments. if (documentName->Length == 0) { throw gcnew ArgumentException("documentName"); } // Create a new XML document. XmlDocument^ xmlDocument = gcnew XmlDocument(); // Format using white spaces. xmlDocument->PreserveWhitespace = true; // Load the passed XML file into the document. xmlDocument->Load(documentName); // Create a new SignedXml object and pass it // the XML document class. SignedXml^ signedXml = gcnew SignedXml(xmlDocument); // Find the "Signature" node and create a new // XmlNodeList object. XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName("Signature"); // Load the signature node. signedXml->LoadXml( (XmlElement^) nodeList->Item(0)); // Check the signature and return the result. return signedXml->CheckSignature(); } }; } int main() { Sample::SignVerifyEnvelope::Work(); }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Signature プロパティ

名前 | 説明 | |
---|---|---|
![]() | Id | 現在の Signature の ID を取得または設定します。 |
![]() | KeyInfo | 現在の Signature の KeyInfo を取得または設定します。 |
![]() | ObjectList | 署名されるオブジェクトのリストを取得または設定します。 |
![]() | SignatureValue | デジタル署名の値を取得または設定します。 |
![]() | SignedInfo | 現在の Signature の SignedInfo を取得または設定します。 |

Signature メソッド

名前 | 説明 | |
---|---|---|
![]() | AddObject | 署名されるオブジェクトのリストに DataObject を追加します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | GetXml | Signature の XML 表現を返します。 |
![]() | LoadXml | XML 要素から Signature の状態を読み込みます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

Signature メンバ
Signature データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | Id | 現在の Signature の ID を取得または設定します。 |
![]() | KeyInfo | 現在の Signature の KeyInfo を取得または設定します。 |
![]() | ObjectList | 署名されるオブジェクトのリストを取得または設定します。 |
![]() | SignatureValue | デジタル署名の値を取得または設定します。 |
![]() | SignedInfo | 現在の Signature の SignedInfo を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | AddObject | 署名されるオブジェクトのリストに DataObject を追加します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | GetXml | Signature の XML 表現を返します。 |
![]() | LoadXml | XML 要素から Signature の状態を読み込みます。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

符号数
(Signature から転送)
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2019/03/17 17:09 UTC 版)
ナビゲーションに移動 検索に移動数学、とくに線型代数学における符号数(ふごうすう、英: signature)は固有値の符号(正・負・零)を重複度を込めて数えたものである。
目次
概観
実有限次元線型空間上の、計量を与える実二次形式および付随する内積(実対称双線型形式)の符号数 (p, q, r) は、これを適当な基底に関して表示した時に得られる同伴実対称行列あるいはそれと同値な計量テンソルの、固有値の符号が正・負・零であるものがそれぞれ重複度込みで p, q, r 個であることを表す。これはそれぞれ正・負・零な部分空間のうち極大なものの次元と言ってもよい。シルヴェスターの慣性法則によれば、これらの数は基底のとり方に依らない。従って符号数は基底の取り方の違いに依らない計量を分類する。
複素係数の場合は、エルミート二次形式およびエルミート半双線型形式を考えれば、同様の結果を得る。
定値性
q = r = 0 のとき計量は正値あるいは正の定符号であるといい、p = r = 0 のとき負値あるいは負の定符号であるという。リーマン計量は定符号であるような計量テンソルである。ローレンツ計量は符号数 (p, 1) または (1, q) を持つものを言う。また、不定符号 (indefinite) あるいは混合型 (mixed) であるとは p, q が何れも非零であるときに言い、退化しているとは r が非零であるときに言う。定符号二次形式の項も参照。
非退化の場合
「非退化」(r = 0)な計量に関して、符号数はしばしば(符号 0 に対応する部分を除く)整数の対として (p, q) と書いたり、あるいは符号数 (1, 3) や (3, 1) を固有値の符号列として明示的にそれぞれ (+, −, −, −) や (−, +, +, +) のように書いたりもする[1]。文献によっては p, q の代わりにひとつの数 s := p − q を符号数と呼ぶこともある。暗黙に全体の次元 n = p + q が与えられていると考えればこの s の意味での符号数から、上で述べた意味での符号数 (p, q) は復元できる。例えば, 符号数 s = 1 − 3 = −2 は (+, −, −, −) のことであり、s = 3 − 1 = +2 は (−, +, +, +) のことである。
性質
符号数と次元の関係
スペクトル論によれば n × n 実対称行列は常に対角化可能であり、したがって(代数重複度を込めて)ちょうど n 個の実固有値を持つから、p + q + r = n を満たす。
シルヴェスターの慣性法則
シルヴェスターの慣性法則によれば、実対称双線型形式としての内積 g の符号数は基底の取り方に依らない。さらに言えば、計量 g が符号数 (p, q, r) を持つとき、
- gab = +1 (a = b = 1, …, p),
- gab = −1 (a = b = p + 1, …, p + q),
- gab = 0 (それ以外)
となるような基底が必ずとれる。これにより、等長同型 (V1, g1) → (V2, g2) が存在するための必要十分条件がg1 および g2 の符号数が等しいことであることが従う。同様にして、合同な行列の符号数は互いに等しく、合同を除いた行列の分類ができる。言葉を替えれば、二階共変対称テンソルの空間 S2V∗ への一般線型群 GL(V) の作用に関する軌道上で符号数は一定であり、これらの軌道を分類する。
各数の幾何学的解釈
符号数 (p,q,r) に対して、p は対称双線型形式 g がその上で正定値となるような部分線型空間の次元の最大値であり、同様に q は負定値となるような部分線型空間の最大値である。また r は g の根基(付随する対称行列の核空間)の次元である。従って、非退化な計量は符号数 (p, q, 0) を持ち、p + q = n を満たす。この特別の場合として (n, 0, 0) および (0, n, 0) はそれぞれ正定値および負定値の内積に対応し、負号反転によって互いに読み替えることができる。
例
対称行列の符号数
次の二つの行列
はともに符号数 (1, 1, 0) を持つから、シルヴェスターの慣性法則によればこれらは互いに合同である。
内積の符号数
数ベクトル空間 Rn の標準内積の符号数は (n, 0, 0) である。実対称双線型形式の意味での内積がこの符号数を持つための必要十分条件は、それが正定符号となることである。
負の定符号内積は符号数 (0, n, 0) を持つ。半負定符号内積は (p, 0, r) (p + r = n) を符号数に持つ。
ミンコフスキー空間は集合としては R4 であり、行列
の定める符号数 (3, 1, 0) の内積を持つ。符号を反転して符号数 (1, 3, 0) とすることもある。
符号数の計算
行列の符号数の計算法はいくつかある。
- n × n非退化対称行列は、対角化して(あるいは固有値を全て求めて)、正符号と負符号の数を数えればよい。
- 対称行列に対して、固有多項式の根が全て実根ならば、デカルトの符号法則から符号数を決定できる。
- ラグランジュアルゴリズムは直交基底を計算することができるから、合同な対角行列を計算してその符号数を決めればよい。
- ヤコビの判定法によれば、対称行列が正定値となる必要十分条件はその主小行列式が全て正であることである。
物理学における符号数
数学においては正定値計量テンソルを備えたリーマン多様体を考えるのが普通である。
理論物理学では時空のモデルとして擬リーマン多様体を用いる。符号数は、時空が(特殊相対論に言う意味で)どのくらい空間的でどのくらい時間的であるかの指標として働く。素粒子物理学での用例では、計量は時間的部分空間上で正定値であり、空間的部分空間上で負定値である。特にミンコフスキー計量
を挙げれば、これは符号数 (1, 3, 0) で、時間方向には正定値、そのほかの三つの空間方向 x, y, z には負定値である。(ここでは s が固有時を直接的にはかるものとして与えているのでこうなるが、符号を逆にする流儀もある。)
符号変化
計量が至る所正則ならば、計量は一定である。しかし、適当な超曲面上で計量が退化したり不連続になったりすることを許すならば、その計量の符号数はそれら曲面上で変化し得る[2]。そのような符号変化をもたらす行列は宇宙論や量子重力論に応用を持ち得る。
関連項目
注釈
- ^ Rowland, Todd. "Matrix Signature." From MathWorld--A Wolfram Web Resource, created by Eric W. Weisstein. http://mathworld.wolfram.com/MatrixSignature.html
- ^ Dray, Tevian; Ellis, George; Hellaby, Charles; Manogue, Corinne A. (1997). “Gravity and signature change”. General Relativity and Gravity 29: 591–597. arXiv:gr-qc/9610063. Bibcode 1997GReGr..29..591D. doi:10.1023/A:1018895302693.
- Signatureのページへのリンク