Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6100721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:25:06+00:00 2026-05-23T13:25:06+00:00

In this exemple where is (e,n,M) ? const size_t BUFFER_SIZE = 64; const size_t

  • 0

In this exemple where is (e,n,M)?

 const size_t BUFFER_SIZE = 64;
    const size_t CIPHER_BUFFER_SIZE = 1024;
    const uint32_t PADDING = kSecPaddingNone;
    static const UInt8 publicKeyIdentifier[] = "com.apple.sample.publickey\0";
    static const UInt8 privateKeyIdentifier[] = "com.apple.sample.privatekey\0";

    SecKeyRef publicKey;
    SecKeyRef privateKey; 

        - (void)encryptWithPublicKey:(uint8_t *)plainBuffer cipherBuffer:(uint8_t *)cipherBuffer
        {
            NSLog(@"== encryptWithPublicKey()");

            OSStatus status = noErr;

            NSLog(@"** original plain text 0: %s", plainBuffer);

            size_t plainBufferSize = strlen((char *)plainBuffer);
            size_t cipherBufferSize = CIPHER_BUFFER_SIZE;
            SecKeyRef key=[self getPublicKeyRef];

            NSLog(@"SecKeyGetBlockSize() public = %d", SecKeyGetBlockSize(key));
            //  Error handling
            // Encrypt using the public.
            status = SecKeyEncrypt([self getPublicKeyRef],
                                   PADDING,
                                   plainBuffer,
                                   plainBufferSize,
                                   &cipherBuffer[0],
                                   &cipherBufferSize
                                   );
            NSLog(@"encryption result code: %d (size: %d)", status, cipherBufferSize);
            NSLog(@"encrypted text: %s", cipherBuffer);
        }


- (SecKeyRef)getPublicKeyRef {
    OSStatus resultCode = noErr;
    SecKeyRef publicKeyReference = NULL;

    if(publicKey == NULL) {
        NSMutableDictionary * queryPublicKey = [[NSMutableDictionary alloc] init];

        NSData *publicTag = [NSData dataWithBytes:publicKeyIdentifier

                                           length:strlen((const char *)publicKeyIdentifier)]; 

        // Set the public key query dictionary.
        [queryPublicKey setObject:(id)kSecClassKey forKey:(id)kSecClass];

        [queryPublicKey setObject:publicTag forKey:(id)kSecAttrApplicationTag];

        [queryPublicKey setObject:(id)kSecAttrKeyTypeRSA forKey:(id)kSecAttrKeyType];

        [queryPublicKey setObject:[NSNumber numberWithBool:YES] forKey:(id)kSecReturnRef];

        // Get the key.
        resultCode = SecItemCopyMatching((CFDictionaryRef)queryPublicKey, (CFTypeRef *)&publicKeyReference);
        NSLog(@"getPublicKey: result code: %d", resultCode);

        if(resultCode != noErr)
        {
            publicKeyReference = NULL;
        }

        [queryPublicKey release];
    } else {
        publicKeyReference = publicKey;
    }

    return publicKeyReference;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T13:25:07+00:00Added an answer on May 23, 2026 at 1:25 pm

    n is not in the example, since you only encrypt here, and this is done with the public key, not the private key.

    m is plainBuffer.

    e is in publicKey which is retrieved with [self getPublicKeyRef].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string as const char *str = Hello, this is an example
like in this post here by exemple I have found this blog but in
This example uses a StringWriter to hold the serialized data, then calling ToString() gives
This example is simplified a bit, but in my ASP.NET web page in my
this example below works when hover event is trigered and when its not, its
This example is taken from w3schools . CREATE TABLE Persons ( P_Id int NOT
This example working great because here containment is body http://jsfiddle.net/roXon/hMmbK/2/ when i use container
This example shows what I am trying to do: http://jsfiddle.net/Dqjvy/ I would like it
Take this example code (ignore it being horribly inefficient for the moment) let listToString
In this example from The Ruby Programming Language (p.270), I'm confused why the instance_eval

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.