1.1 --- a/MYPrivateKey.m Sun Apr 19 00:01:41 2009 -0700
1.2 +++ b/MYPrivateKey.m Tue Jun 02 13:16:28 2009 -0700
1.3 @@ -340,19 +340,23 @@
1.4 // Now unwrap the key:
1.5 MYSymmetricKey *result = nil;
1.6 CSSM_KEY *unwrappedKey = calloc(1,sizeof(CSSM_KEY));
1.7 - CSSM_DATA desc = {};
1.8 + CSSM_DATA label = {.Data=(void*)"Imported key", .Length=strlen("Imported key")};
1.9 + CSSM_DATA descriptiveData = {};
1.10 if (checkcssm(CSSM_UnwrapKey(ctx,
1.11 self.cssmKey,
1.12 &wrappedKey,
1.13 wrappedKey.KeyHeader.KeyUsage,
1.14 wrappedKey.KeyHeader.KeyAttr,
1.15 - NULL, NULL,
1.16 + &label,
1.17 + NULL,
1.18 unwrappedKey,
1.19 - &desc),
1.20 + &descriptiveData),
1.21 @"CSSM_UnwrapKey")) {
1.22 result = [[[MYSymmetricKey alloc] _initWithCSSMKey: unwrappedKey] autorelease];
1.23 }
1.24 // Finally, delete the context
1.25 + if (!result)
1.26 + free(unwrappedKey);
1.27 CSSM_DeleteContext(ctx);
1.28 return result;
1.29 }
1.30 @@ -361,3 +365,27 @@
1.31 #endif !TARGET_OS_IPHONE
1.32
1.33 @end
1.34 +
1.35 +
1.36 +
1.37 +/*
1.38 + Copyright (c) 2009, Jens Alfke <jens@mooseyard.com>. All rights reserved.
1.39 +
1.40 + Redistribution and use in source and binary forms, with or without modification, are permitted
1.41 + provided that the following conditions are met:
1.42 +
1.43 + * Redistributions of source code must retain the above copyright notice, this list of conditions
1.44 + and the following disclaimer.
1.45 + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
1.46 + and the following disclaimer in the documentation and/or other materials provided with the
1.47 + distribution.
1.48 +
1.49 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
1.50 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
1.51 + FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRI-
1.52 + BUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1.53 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
1.54 + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1.55 + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
1.56 + THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.57 + */