Inheritance: INativeObject, IDisposable
Esempio n. 1
0
        // TODO: pull all the TypeRefs needed for the NSDictionary
        public static SecStatusCode GenerateKeyPair(NSDictionary parameters, out SecKey publicKey, out SecKey privateKey)
        {
            if (parameters == null)
                throw new ArgumentNullException ("parameters");

            IntPtr pub, priv;

            var res = SecKeyGeneratePair (parameters.Handle, out pub, out priv);
            if (res == SecStatusCode.Success){
                publicKey = new SecKey (pub, true);
                privateKey = new SecKey (priv, true);
            } else
                publicKey = privateKey = null;
            return res;
        }
Esempio n. 2
0
        public static SecStatusCode TryQueryAsConcreteType(SecRecord query, out object result)
        {
            if (query == null){
                result = null;
                return SecStatusCode.Param;
            }

            using (var copy = NSMutableDictionary.FromDictionary (query.queryDict)){
                copy.SetObject (CFBoolean.TrueObject, SecItem.ReturnRef);

                IntPtr ptr;
                var ret = SecItem.CopyMatching (copy, out ptr);
                if (ret == SecStatusCode.Success){
                    int cfType = CFType.GetTypeID (ptr);

                    if (cfType == SecCertificate.GetTypeID ())
                        result = new SecCertificate (ptr, true);
                    else if (cfType == SecKey.GetTypeID ())
                        result = new SecKey (ptr, true);
                    else if (cfType == SecIdentity.GetTypeID ())
                        result = new SecIdentity (ptr, true);
                    else
                        throw new Exception (String.Format ("Unexpected type: 0x{0:x}", ret));
                    result = null;
                } else
                    result = null;
                return ret;
            }
        }