]>
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
{
43 class Digester
; friend class Digester
;
48 OSXSignature
*sign(const Signable
&target
);
49 bool verify(const Signable
&target
, const Signature
*signature
);
51 OSXSignature
*restore(uint32 type
, const void *data
, size_t length
);
54 class OSXSignature
: public Signature
{
56 static const size_t hashLength
= 20; // length of signature data
57 typedef uint8 Hash
[hashLength
];
59 OSXSignature(const void *src
) { memcpy(mData
, src
, hashLength
); }
61 bool operator == (const Signature
&other
) const
63 if (const OSXSignature
*sig
= dynamic_cast<const OSXSignature
*>(&other
))
64 return !memcmp(mData
, sig
->mData
, hashLength
);
69 bool operator == (void *bytes
) const
70 { return !memcmp(mData
, bytes
, hashLength
); }
72 uint32
type() const { return standardOSXSignature
; }
73 const void *data() const { return mData
; }
74 size_t length() const { return hashLength
; }
77 uint8 mData
[hashLength
];
81 class Digester
: public State
, public CssmClient::Digest
{
83 Digester(OSXSigner
&sgn
) : State(sgn
), CssmClient::Digest(sgn
.csp
, CSSM_ALGID_SHA1
) { }
85 void enumerateContents(const void *addr
, size_t length
);
93 } // end namespace CodeSigning
95 } // end namespace Security
102 #endif //_H_OSXSIGNER