Bug 34135 - Need some constants exposed in Xamarin.iOS binding
Summary: Need some constants exposed in Xamarin.iOS binding
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll (show other bugs)
Version: XI 9.0 (iOS9)
Hardware: Macintosh Mac OS
: Normal minor
Target Milestone: 15.7
Assignee: Vincent Dondain [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2015-09-21 16:11 UTC by Mark Smith
Modified: 2018-02-15 04:37 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Mark Smith 2015-09-21 16:11:36 UTC
When using SecKey.GenerateKeyPair, you need to pass in an NSDictionary with the properties for the public/private key pairs being generated. Apple's documentation uses the following constants:

kSecPrivateKeyAttrs, kSecAttrKeyType, kSecKeySizeInBits, kSecAttrIsPermanent and kSecAttrApplicationTag

I see the properties exposed on SecRecord which are using these keys internally, but it appears this is primarily for keychain access, and the actual key isn't exposed.

We are currently using dlfcn to get to the constants, but it would be useful to have some public constants exposed on some of the classes to get to these.
Comment 1 Larry O'Brien 2017-07-24 21:31:42 UTC
Thanks so much for taking the time to submit this report! I can confirm using the latest Xamarin.iOS 10.12.0.14 I am able to reproduce this issue. Marking this report as CONFIRMED. 

--- 

I cannot find any binding for `kSecPrivateKeyAttrs` and that is a valid key (https://developer.apple.com/documentation/security/ksecprivatekeyattrs) 

The others look to be defined in `internal unsafe static partial class SecAttributeKey`: 

`kSecAttryKeyType` is bound as `SecAttributeKey.KeyType`

`kSecKeySizeInBits` is bound as `SecAttributeKey.KeySizeInBits`

`kSecAttrIsPermanent` is bound as `SecAttributeKey.IsPermanent`

`kSecAttrApplicationTag` is bound as `SecAttributeKey.ApplicationTag`
Comment 2 Vincent Dondain [MSFT] 2018-02-09 20:55:35 UTC
Hi,

https://github.com/xamarin/xamarin-macios/pull/3438 addresses the issue of the missing `kSecPrivateKeyAttrs` and `kSecPublicKeyAttrs`.

New APIs now take a strongly typed dictionary with the relevant attributes (keys) and pass them to the private and public keys on iOS (or merge those attributes with the existing dictionary). See https://developer.apple.com/documentation/security/1395339-seckeygeneratepair?language=objc for more details.

Let me know if you have any questions or have feedback on the new APIs. A build should be available soon to try them out (I'll link it here).