Questions tagged [seckeyref]

Certificate, Key, and Trust Services provides a C API for managing certificates, public and private keys, and trust policies. You can use this services in your application.

To read more visit below link:

Apple developer library

29 questions
16
votes
2 answers

Create SecKey from modulus and exponent in swift

I try to make my own SecKey with exponent: let exponent = "10001" modulus: let modulus =…
Will Cai
  • 161
  • 1
  • 4
9
votes
1 answer

Swift 3 export SecKey to String

I am developing an iOS app using swift 3. I need to export an SecKey (which is the user RSA publickey reference) to a string (e.g base64) in order to share it through a generated QRCode. It also has to work the other way since the other user that…
Scaraux
  • 3,841
  • 4
  • 40
  • 80
9
votes
3 answers

Seckey from public key string from server in Swift

I want to encrypt data using RSA , I tried to generate the key in my code and it's working , But what I actually need is to get the public key as a string from server and then use it as Seckey so I can use it to encrypt data using RSA, I tried this…
4
votes
3 answers

Retrieve SecKey from NSData

I encountered an issue with creating SecKey from NSData. Basically my client-server communication is based on signature created with private key and verified on the server with public key. I am implementing session transfer between two devices and…
Oleg Novosad
  • 2,261
  • 1
  • 27
  • 28
4
votes
1 answer

SecKeyRef causes EXC_BAD_ACCESS (code=1) error when using SecItemCopyMatching

I'm fairly new to crypto on iOS, and I've been running into an error that I haven't been able to find a solution for: Whenever I try to get a SecKeyRef to a public key in the iOS keychain and use it, I end up with a EXC_BAD_ACCESS error. The…
3
votes
0 answers

Verify signature on iOS and OSx without external libraries (-9809 OSStatus error)

I create public key using SecKeyCreateWithData. Key is created from Pem after stripping the headers. I have tried to verify signature using SecKeyRawVerify returns -9809 error (iOS) SecKeyVerifySignature returns -67808 "RSA signature verification…
D12sd
  • 31
  • 1
2
votes
1 answer

PEM-encoded Elliptic Curve public key conversion iOS

In an iOS application, I receive a PEM-encoded Elliptic curve public key. I would like to create a SecKey object from it. This question has been very useful to get RSA key parsing to work. But I struggle adapting it to work with an EC key. Example…
Chralu
  • 43
  • 4
2
votes
1 answer

Convert ECPublicKey(SecKey) to PEM String in swift

I want to convert ECPublicKey to PEM format as below "-----BEGIN PUBLIC KEY-----MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEo0WcFrFClvBE8iZ1Gdlj+mTgZoJWMNE3kDKTfRny2iaguwuSYxo+jCnXqzkR+kyFK9CR3D+pypD1sGb1BnfWAA==-----END PUBLIC KEY-----" Generated…
UdayM
  • 1,725
  • 16
  • 34
2
votes
0 answers

Create secKey form data/hex/bytes using SecKeyCreateWithData give nil

I'm new to encryption. i want to create public seckey from data but i always get nil. Please help me. I need this public key as seckey to create a shared secrete key but i always get nil . how i can convert data to seckey? Below are the code for…
Sourav Mishra
  • 501
  • 4
  • 21
2
votes
1 answer

Is there any way to get the key type of a SecKey?

Given a SecKey, is there any way to infer its type (e.g. whether it is kSecAttrKeyTypeRSA or kSecAttrKeyTypeEC)? I see SecKeyGetTypeID(), but it is unclear to me what key object this function operates on as it accepts no parameters.
Adam Johns
  • 35,397
  • 25
  • 123
  • 176
2
votes
0 answers

How to get the type of encryption used in a SecKey?

I get a SecKey from given certificates. Depending on the certificate, the SecKey can use either RSA or EllipticCurve encryption. let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, certificateData) let certArray = […
2
votes
2 answers

Generate a P12 file Xcode?

I know there is a function called SecPKCS12Import that allows you to import data from a p12 file. However, I want to go the reverse route. I have a SecCertificateRef and a public/private SecKeyRef, which I want to use to create a P12 file. Does…
hockeybro
  • 981
  • 1
  • 13
  • 41
2
votes
0 answers

Swift: How can I send a SecKey to another peer?

I'm writing a chat application for iOS using Swift. To reach this, I'm using Multipeer Connectivity. As soon as a new peer connects, he should be given the session key. Therefore the new peer has to send his public key (which is of type SecKey) to…
user3748930
  • 241
  • 1
  • 2
  • 5
2
votes
1 answer

SecKeyRawSign returns OSStatus = noErr, but random signature objects

I am using SecKeyRawSign to digitally sign a PDF´s SHA digest, and SecKeyRawSign reports OSStatus = noErr, but I get random signature objects every time I run the project. The privateKey is always the same (saved in the Keychain). I also verified…
eharo2
  • 2,553
  • 1
  • 29
  • 39
1
vote
1 answer

Saving and Reading SecKey to Keychain

I save a key to keychain and read it back to compare the result. Thing is: Values are now different. Any idea what could be wrong? Here is how I read and write a SecKey: var privateKey: SecKey?{ get{ let query: [String: Any] = [ …
netshark1000
  • 7,245
  • 9
  • 59
  • 116
1
2