]>
git.saurik.com Git - apple/security.git/blob - cdsa/cdsa_client/osxsigner.h
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 // osxsigner - MacOS X's standard code signing algorithm.
25 #include <Security/osxsigning.h>
26 #include <Security/cspclient.h>
40 // The OSX standard signer object
42 class OSXSigner
: public Signer
{
44 class Digester
; friend class Digester
;
47 OSXSignature
*sign(const Signable
&target
);
48 bool verify(const Signable
&target
, const Signature
*signature
);
50 OSXSignature
*restore(uint32 type
, const void *data
, size_t length
);
53 class OSXSignature
: public Signature
{
55 static const size_t hashLength
= 20; // length of signature data
56 typedef uint8 Hash
[hashLength
];
58 OSXSignature(const void *src
) { memcpy(mData
, src
, hashLength
); }
60 bool operator == (const Signature
&other
) const
62 if (const OSXSignature
*sig
= dynamic_cast<const OSXSignature
*>(&other
))
63 return !memcmp(mData
, sig
->mData
, hashLength
);
68 bool operator == (void *bytes
) const
69 { return !memcmp(mData
, bytes
, hashLength
); }
71 uint32
type() const { return standardOSXSignature
; }
72 const void *data() const { return mData
; }
73 size_t length() const { return hashLength
; }
76 uint8 mData
[hashLength
];
80 class Digester
: public State
, public CssmClient::Digest
{
82 Digester(OSXSigner
&sgn
) : State(sgn
), CssmClient::Digest(sgn
.csp
, CSSM_ALGID_SHA1
) { }
84 void enumerateContents(const void *addr
, size_t length
);
92 } // end namespace CodeSigning
94 } // end namespace Security
101 #endif //_H_OSXSIGNER