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
This example is from php.net: <?php function Test() { static $a = 0; echo
Example from MSVC's implementation: #define offsetof(s,m) \ (size_t)&reinterpret_cast<const volatile char&>((((s *)0)->m)) // ^^^^^^^^^^^ As
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
Given this example: <img class=a /> <img /> <img class=a /> <img class=a id=active
Consider this example table (assuming SQL Server 2005): create table product_bill_of_materials ( parent_product_id int
Consider this example (typical in OOP books): I have an Animal class, where each

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.