question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reintroduce GetAsymmetricAlgorithm/GetSymmetricAlgorithm

See original GitHub issue

The base AsymmetricSecurityKey and SymmetricSecurityKey classes should expose GetAsymmetricAlgorithm/GetSymmetricAlgorithm to allow retrieving the underlying algorithm without having to cast the security key to known types.

@brentschmaltz any chance we could bring back these APIs for RTM?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (19 by maintainers)

github_iconTop GitHub Comments

1reaction
kevinchaletcommented, May 11, 2016

@tushargupta51 for RC2, it’s of course too late, that’s why I suggested keeping the API as-is (no rollback) and adding the necessary stuff in the next milestone 👍

Your approach seems fine, and it’s pretty close to what CryptoConfig offers:

public override bool IsSupportedAlgorithm(string algorithm)
{
    if (string.IsNullOrEmpty(algorithm))
    {
        throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(algorithm, SR.GetString(SR.EmptyOrNullArgumentString, "algorithm"));
    }

    object algorithmObject = null;

    try
    {
        algorithmObject = CryptoHelper.GetAlgorithmFromConfig(algorithm);
    }
    catch (InvalidOperationException)
    {
        algorithmObject = null;
    }

    if (algorithmObject != null)
    {
        SignatureDescription signatureDescription = algorithmObject as SignatureDescription;
        if (signatureDescription != null)
            return true;
        AsymmetricAlgorithm asymmetricAlgorithm = algorithmObject as AsymmetricAlgorithm;
        if (asymmetricAlgorithm != null)
            return true;
        return false;
    }

    switch (algorithm)
    {
        case SecurityAlgorithms.RsaV15KeyWrap:
        case SecurityAlgorithms.RsaOaepKeyWrap:
        case SecurityAlgorithms.RsaSha1Signature:
        case SecurityAlgorithms.RsaSha256Signature:
            return true;
        default:
            return false;
    }
}
0reactions
kevinchaletcommented, Jun 14, 2018

A key has only data. A provider knows how to interact with the underlying layers to produce the correct crypto operations.

Care to share more information or better, write a sample about how to achieve the desired result without the suggested APIs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Asymmetric and Symmetric Encryption | by Laurent Balmelli
In a symmetric encryption scheme, once a key has been decided by the parties, the encryption of the plain text can now begin....
Read more >
Cryptography: Symmetric vs Asymmetric Encryption
Asymmetrical encryption is hardly ever used to directly encrypt large amounts of data, unlike symmetric; it increases the size of the cryptogram ...
Read more >
Asymmetric Encryption - an overview
Asymmetric and symmetric encryption are typically used together: use an asymmetric algorithm such as RSA to securely send someone an AES (symmetric) key....
Read more >
Asymmetric Encryption for Multiple Recipients?
So encrypting just a symmetric key with the expensive asymmetric algorithm and then using that symmetric key for the bulk of the message...
Read more >
Symmetric and Asymmetric Encryption INTRODUCTION
These se- cret keys are used in the encryption process to introduce uncertainty (to the unauthor- ized receiver), which can be removed in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found