RSA Key generation with SecKey Xamarin.iOS












0















I'm trying to generate a public (and private) key pair using the SecKey class from Xamarin.iOS.
The KeySize is defined to 1024 bit and this seems to work (if I change this value, the length of the result array is changing too).



I generate the keys with



SecKey.GenerateKeyPair(CreateRsaParams(), out publicKey, out privateKey); 
byte key = publicKey.GetExternalRepresentation().ToArray()


(CreateRsaParams() is a function giving back a NSDictionary with the required data)



The problem is: I get a byte array (public key) with 140 Bytes - but depended on the key size it should have only 128 Byte - and I need a 128 Byte public key for data exchange with an other system



(by the way - using PCLCrypto is not an option for me since the project is not allowed to use this 3rd party component)



Does anyone know the problem and know a solution?










share|improve this question























  • Refer this blog msicc.net/tag/rsa

    – Lucas Zhang - MSFT
    Nov 23 '18 at 2:55











  • Thanks Lucas for the link. I already used most of the code from this blog. Now I changed completely to this code and use the key chain - but the result is the same 140 byte key. So the problem isn't solved.

    – Peter
    Nov 23 '18 at 10:32
















0















I'm trying to generate a public (and private) key pair using the SecKey class from Xamarin.iOS.
The KeySize is defined to 1024 bit and this seems to work (if I change this value, the length of the result array is changing too).



I generate the keys with



SecKey.GenerateKeyPair(CreateRsaParams(), out publicKey, out privateKey); 
byte key = publicKey.GetExternalRepresentation().ToArray()


(CreateRsaParams() is a function giving back a NSDictionary with the required data)



The problem is: I get a byte array (public key) with 140 Bytes - but depended on the key size it should have only 128 Byte - and I need a 128 Byte public key for data exchange with an other system



(by the way - using PCLCrypto is not an option for me since the project is not allowed to use this 3rd party component)



Does anyone know the problem and know a solution?










share|improve this question























  • Refer this blog msicc.net/tag/rsa

    – Lucas Zhang - MSFT
    Nov 23 '18 at 2:55











  • Thanks Lucas for the link. I already used most of the code from this blog. Now I changed completely to this code and use the key chain - but the result is the same 140 byte key. So the problem isn't solved.

    – Peter
    Nov 23 '18 at 10:32














0












0








0








I'm trying to generate a public (and private) key pair using the SecKey class from Xamarin.iOS.
The KeySize is defined to 1024 bit and this seems to work (if I change this value, the length of the result array is changing too).



I generate the keys with



SecKey.GenerateKeyPair(CreateRsaParams(), out publicKey, out privateKey); 
byte key = publicKey.GetExternalRepresentation().ToArray()


(CreateRsaParams() is a function giving back a NSDictionary with the required data)



The problem is: I get a byte array (public key) with 140 Bytes - but depended on the key size it should have only 128 Byte - and I need a 128 Byte public key for data exchange with an other system



(by the way - using PCLCrypto is not an option for me since the project is not allowed to use this 3rd party component)



Does anyone know the problem and know a solution?










share|improve this question














I'm trying to generate a public (and private) key pair using the SecKey class from Xamarin.iOS.
The KeySize is defined to 1024 bit and this seems to work (if I change this value, the length of the result array is changing too).



I generate the keys with



SecKey.GenerateKeyPair(CreateRsaParams(), out publicKey, out privateKey); 
byte key = publicKey.GetExternalRepresentation().ToArray()


(CreateRsaParams() is a function giving back a NSDictionary with the required data)



The problem is: I get a byte array (public key) with 140 Bytes - but depended on the key size it should have only 128 Byte - and I need a 128 Byte public key for data exchange with an other system



(by the way - using PCLCrypto is not an option for me since the project is not allowed to use this 3rd party component)



Does anyone know the problem and know a solution?







ios xamarin rsa public-key






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 10:21









PeterPeter

1




1













  • Refer this blog msicc.net/tag/rsa

    – Lucas Zhang - MSFT
    Nov 23 '18 at 2:55











  • Thanks Lucas for the link. I already used most of the code from this blog. Now I changed completely to this code and use the key chain - but the result is the same 140 byte key. So the problem isn't solved.

    – Peter
    Nov 23 '18 at 10:32



















  • Refer this blog msicc.net/tag/rsa

    – Lucas Zhang - MSFT
    Nov 23 '18 at 2:55











  • Thanks Lucas for the link. I already used most of the code from this blog. Now I changed completely to this code and use the key chain - but the result is the same 140 byte key. So the problem isn't solved.

    – Peter
    Nov 23 '18 at 10:32

















Refer this blog msicc.net/tag/rsa

– Lucas Zhang - MSFT
Nov 23 '18 at 2:55





Refer this blog msicc.net/tag/rsa

– Lucas Zhang - MSFT
Nov 23 '18 at 2:55













Thanks Lucas for the link. I already used most of the code from this blog. Now I changed completely to this code and use the key chain - but the result is the same 140 byte key. So the problem isn't solved.

– Peter
Nov 23 '18 at 10:32





Thanks Lucas for the link. I already used most of the code from this blog. Now I changed completely to this code and use the key chain - but the result is the same 140 byte key. So the problem isn't solved.

– Peter
Nov 23 '18 at 10:32












1 Answer
1






active

oldest

votes


















0














Okay, problem solved.
If anyone is facing the same problem, you can find the solution at
https://forums.developer.apple.com/thread/111109



The problem was not the key, but the wrongly formulated requirement.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428741%2frsa-key-generation-with-seckey-xamarin-ios%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Okay, problem solved.
    If anyone is facing the same problem, you can find the solution at
    https://forums.developer.apple.com/thread/111109



    The problem was not the key, but the wrongly formulated requirement.






    share|improve this answer




























      0














      Okay, problem solved.
      If anyone is facing the same problem, you can find the solution at
      https://forums.developer.apple.com/thread/111109



      The problem was not the key, but the wrongly formulated requirement.






      share|improve this answer


























        0












        0








        0







        Okay, problem solved.
        If anyone is facing the same problem, you can find the solution at
        https://forums.developer.apple.com/thread/111109



        The problem was not the key, but the wrongly formulated requirement.






        share|improve this answer













        Okay, problem solved.
        If anyone is facing the same problem, you can find the solution at
        https://forums.developer.apple.com/thread/111109



        The problem was not the key, but the wrongly formulated requirement.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 28 '18 at 13:14









        PeterPeter

        1




        1






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53428741%2frsa-key-generation-with-seckey-xamarin-ios%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            404 Error Contact Form 7 ajax form submitting

            How to know if a Active Directory user can login interactively

            TypeError: fit_transform() missing 1 required positional argument: 'X'