在iOS上通过X509证书制作xml节点的数字标牌

时间:2014-06-11 12:10:07

标签: objective-c digital-signature x509

我在iOS上的钥匙链上有一个X509证书。 我如何制作(和写入)xml的数字签名,如xml。不是字符串。我需要通过数字签名来保护XML文档的各个节点。 我怎么能在Objective-C上做到这一点?

    <eps:Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:eps="urn-zaoeps-schemas-docmanagement">
  <eps:DocumentData Id="{2c477639-f9ef-4955-91fb-ca8713ae8e31}">
    <eps:DocumentNumber>19</eps:DocumentNumber>
    <eps:Customer>Coca-Cola</eps:Customer>
    <eps:Topic>5</eps:Topic>
    <eps:Vendor>Peroni</eps:Vendor>
    <eps:Subject>Glass</eps:Subject>
    <eps:SignedAttachments>
      <eps:Attachment Name="Brif" DbId="{540880e7-96cd-4173-a76b-e42653f11af1}" IsApproved="false" Extension="doc">
        <eps:RelativePath>/540880e796cd4173a76be42653f11af1/Brif.doc</eps:RelativePath>
        <eps:Hash>1QBSw0+kbRbVGcHSbJIMuyQF8OA=</eps:Hash>
      </eps:Attachment>
    </eps:SignedAttachments>
  </eps:DocumentData>
  <eps:SignatureContainer>
    <eps:Signatures>
      <Signature Id="{82116185-ac2a-4af4-9d9d-ac304b4c20ed}" xmlns="http://www.w3.org/2000/09/xmldsig#">
        <SignedInfo>
          <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
          <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
          <Reference URI="#{2c477639-f9ef-4955-91fb-ca8713ae8e31}">
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>EmL07BOUnxW6QNgo5iTmKUtq2RQ=</DigestValue>
          </Reference>
          <Reference URI="#{e138da73-a971-4de2-b3a2-d050e53bfcdc}">
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>0Ivb7ArrzbEQ/QqC0f3isk9bf9c=</DigestValue>
          </Reference>
        </SignedInfo>
        <SignatureValue>oa3dYTM8yvrNUFytNWWLtSwoeRNhGe5R8DU/wVrx2nP2yxyxXOy5oHlnfkPkbBy4OWahm914QaShfpnVQVjvf1emYLgTG8swECVYDulyH97/vgJ+IUe8uMjyFnZWpTt2xBVoqprUSWRBUriXr5pAxqDLMYzgHazOB8LOJ3wIf5k=</SignatureValue>
        <KeyInfo>
......

1 个答案:

答案 0 :(得分:0)

我并不了解您需要做什么,但这里有一些图书馆参考资料可能对您有帮助。

GDataXML是谷歌的XML解析器和创建者。

OAuth Obj-c有一些有用的类,如OAHMAC_SHA1SignatureProvider for。

Apple's Encryption Guide