Questions tagged [crypto]
The crypto tag has no usage guidance.
129
questions
0
votes
0
answers
63
views
Fetch principal values from External Credential without callout
Is there a way to access principal's authentication details from ExternalCredential in apex.
I tried:
ConnectApi.ExternalCredential ec = ConnectApi.NamedCredentials.getExternalCredential('GCP_Key');
...
2
votes
1
answer
33
views
Encryption via managed package
In my current project we are trying to redirect a logged in user from a webpage to a salesforce community page with guest user access. We want the community page to recognize the user and so we are ...
1
vote
0
answers
143
views
Failed to create a Valid JWT token
I am currently working on sending a request to Snowflake using Key Pair Authentication. They have provided me with a private key and a public key, and for testing purposes, I have hardcoded them as ...
0
votes
0
answers
197
views
Decryption of Data failing in API calls
We have an Apex method in our Org which is exposed for a GET API request. The data is encrypted with AES256 before sending. However from the receiver end (Same Org for testing purpose), decryption of ...
0
votes
1
answer
5k
views
Why am I getting "Input length must be multiple of 16 when decrypting with padded" error?
I'm writing an apex class to receive incoming AES256 encrypted data. I have a private key safely stored, and the incoming data includes an iv.
My logs show me that the retrieved private key is 32 ...
0
votes
1
answer
521
views
AMPScript AES Encrypted and Decrypt with Crypto Apex Class
I'm trying to decrypt the example that AMPScript has in the documentation https://ampscript.guide/encryptsymmetric/ using Crypto class.
I have desperately tried all the scenarios but I don't know if ...
0
votes
0
answers
257
views
OAuth1 sign a request with Crypto.generateHash
I'm trying to connect to a distant API (Netsuite).
I can send a request and get a successful response when connecting with Postman.
But when I try to do the same in Apex I get a 401 response. I ...
2
votes
1
answer
199
views
Generate Cybersource digest in Apex
Cybersource is asking to generate a digest from payload using byte array. However we don't have bytes in apex. I'm getting SHA-256=k3t9b6mL4zCMDTOi7N1uLQMu9XxrjwOr5yRXnTG0G1A= hash when I try to ...
1
vote
1
answer
504
views
Retrieve claims from a jwt with apex
I'm trying to retrieve the claims, audience, issuer, subject from a JWT in apex, according to this documentation:
https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/...
0
votes
0
answers
453
views
How to verify a JWT id token signature in an Apex Class
I try to verify a JWT signature in an apex class.
It is a RS SHA 256 token.
It is an id token received from Auth0.
Blob bPublicKey = EncodingUtil.base64Decode(publicKey);
Blob bsignature = ...
0
votes
1
answer
202
views
How to encrypt with unknown initialization vector?
How can I generate an AES encrypted token with a shared key and using the following AES cipher attributes in apex?
Rijndael cipher
Electronic Code Book mode (ECB) / Galois Counter Mode (GCM)
No built ...
0
votes
0
answers
194
views
Validate SHA1 signed Payload
I am trying to validate SHA1 signed data sent to Salesforce through webhook json message. I am getting the error System.SecurityException: Invalid Crypto Key
I have PEM format public key. According to ...
1
vote
0
answers
345
views
Problems signing with Crypto.signWithCertificate()
I am trying to connect with an external service, which in its documentation asks me to generate a CMS from an XML and a certificate and private key with openssl :
In salesforce use "Certificate ...
0
votes
0
answers
191
views
Acquire access token via oAuth from Azure Active Directory
I'm using Crypto.signWithCertificate with a certificate in the Certificate and Key Management area. The platform I'm accessing (AAD) requires thumbprint of the certificate as part of the client ...
0
votes
1
answer
257
views
Payload encryption
We have a large request payload and customer would like to encrypt it before sending.Since SF crypto class have a limitation of 1MB , customer has asked us if it is possible to only encrypt the values ...
0
votes
1
answer
360
views
File encryption using Crypto in apex
I am trying to encrypt and decrypt file using apex but getting below error while decryption of file. Goal is to encrypt the file in salesforce and send it to third party. Third party should be able to ...
1
vote
1
answer
460
views
Decrypt Symmetrically/Asymmetrically Encrypted Data in MS SQL (T-SQL) Server via Apex Crypto Class
Hope you're doing well. Recently, I have been working on a project and haven't been able to find a solution to this problem.
What I want to achieve is: To decrypt the data in Apex using the crypto ...
1
vote
1
answer
363
views
Uniqueness of generated with Crypto.generateAesKey(128)
I want to generate a unique text for integration purposes using the following code fragment.
Blob cryptoKey = Crypto.generateAesKey(128);
String key = EncodingUtil.convertToHex(cryptoKey);
I ...
0
votes
0
answers
1k
views
How do I import a JKS where I do not have the private key
The public cert is issued by the claims provider.
It is for custom apex JWT verification. I get an error when uploading:
"Error: No certificate was imported because the keystore file doesn't ...
0
votes
1
answer
186
views
Removing Initialization Vector from Cipher Text
public static string getencRequest(){
String PLAIN_Request = 'merchant_id=90578&order_id=456¤cy=INR&amount=1.00&redirect_url=https://ceptes-sf-webhook-developer-edition....
1
vote
1
answer
1k
views
Verify Signature with PEM Public Key
In Apex, how do I implement the webhook verification from Ironclad described here?
Their example uses Node.js and basically boils down to this:
const isValid = crypto
.createVerify(signAlgorithm)
...
0
votes
1
answer
1k
views
Verify ECDSA signature from Ethereum signed message hash
For my use case I need to verify a ECDSA signature from a signed Ethereum message.
From the front end, the message is first converted into a Sha3/keccac256 hash using web3.js with below method:
https:/...
1
vote
1
answer
735
views
Salesforce APEX Crypto hash vs Javascript Crypto hash
Trying to generate a hash of a HMAC Sring in Salesforce. The hash generated using APEX in Salesforce is not identical when compared to a hash generated by JS code on the same message. Am I doing ...
1
vote
1
answer
5k
views
String encrypted using Crypto js can not decrypted via Crypto apex
We are encrypting a string using Crypto js library.
And we want to decrypt that encrypted string using Crypto apex class. But unfortunately, that is not working.
JS Code
CryptoJS.AES.encrypt('123', '...
0
votes
1
answer
1k
views
Encrypt File Using Crypto JS in Aura Component
We want to encrypt the input file on client side using javascript in our aura component.
We are trying to use CryptoJS(https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js).
We have ...
3
votes
0
answers
480
views
Does APEX language support ES256 algorithm?
I'm trying to implement social login via Apple.
When requesting an access token, I get an "invalid_client" error.
I found that one cause for this issue is a bad-formatted JWT, which is ...
0
votes
1
answer
633
views
Is it possible to decrypt a message in APEX using asymmetric RSA algorithm? [closed]
I know that Salesforce supports symmetric AES-based encryption(Crypto Class). What if I need to decrypt a message in salesforce which is encrypted using asymmetric RSA?
1
vote
1
answer
977
views
Export public key from the certificate
I want to understand if there is a way to export a public key using any crypto methods, the way openssl is generating.
I am able to successful generate public key with the following command, however I ...
0
votes
1
answer
114
views
How to pass key from an apex class to Visualforce controller class?
I have created a process builder which invokes apex class when a checkbox is true and it adds the encrypted Id and encrypted key to the fields in opportunity records.
The issue is that when I am ...
4
votes
1
answer
1k
views
How Verify HMAC in Salesforce
Any ideas what I am doing wrong?
Data = '1605470404trashed';
Private Key = '5034eafbf7068b76e4762db248effd77';
Algoithm: SHA256
Actual HMAC generated from service = ...
1
vote
1
answer
595
views
ENS - Signature Verification
I followed the Transactional API Notification Signing steps as mentioned in the document here.
And I get following signature key as a response on calling the endpoint /platform/v1/ens-callbacks
//...
2
votes
0
answers
807
views
AES256 decryption problem with PKCS7 Padding
I have an encrypted token(Encrypted in Java system with AES256 algorithm and PKCS7 padding).
when I try to decrypt in SF using crypto class. some of the information is missing from the original token.
...
0
votes
1
answer
908
views
Decrypting a PGP File from SFTP Server
Problem
The client that I am working with is asking us to encrypt (Using PGP or GPG) files from marketing cloud and insert them onto an SFTP Server. Then, we should create a separate Node JS ...
1
vote
3
answers
4k
views
How to encrypt text in apex using sha512 algorighm?
I have an urgent business requirement which requires verification of user credentials. We need to encrypt the credentials using sha512 algorithm and then compare it with already encrypted text fields ...
1
vote
0
answers
250
views
Is there a way to convert JWK to x.509 cert in Apex salesforce
Is there any way in APEX Salesforce to convert JWK to x.509 cert so that the Crypto class can be used to verify another JWT ?
0
votes
1
answer
1k
views
Encrypting the password [duplicate]
I have a custom objects which will have user information fields and password fields.
Also i have custom LWC (salesforce site) with Username and password. Password has to store in encrypt value.
...
1
vote
1
answer
364
views
Payeezy credit card payment integration using HMAC [duplicate]
I was recently working on Payeezy (link) integration with sales force. Payeezy was using HMAC to generate authorization header with help of certain apiKey, Token, TimStamp, Nonce and API Secret key. ...
3
votes
2
answers
6k
views
SHA256 Algorithm
I have to apply SHA256 algorithm to a string. As the Salesforce document says, I have used the method SHA256('myString', 'UTF-8') and its giving an error as 'Method not exists'
1
vote
2
answers
2k
views
Crypto.verify(..) - format of a public RSA key
I'm actually using an apex implementation of jwt for the rsa256 cryptography type using this class from github : https://github.com/salesforceidentity/jwt.
I have been able to generate a signature ...
3
votes
2
answers
3k
views
Encryption / decryption with AES
I have an integration with another system which I should use the AES Algorithm.The Encryption is made in SF side - and sent in the header of an HTTP request. This made to recognize SF in internal ...
1
vote
1
answer
847
views
Encrypt with Apex and decrypt with OpenSSL - base64 encoding and line breaks
Reposting the post to Salesforce forum from Network security forum:
I am encrypting a file with Crypto class and trying to Decrypt in Open SSL and facing issues. The same source file encrypted in ...
5
votes
2
answers
3k
views
Using the Crypto.verify() method to verify a JWT signature
I am trying to validate a JWT in apex by using the Crypto.verify() method, however, it always returns false despite the fact that I know it is valid. I know it valid because a) I created it and b) I ...
0
votes
1
answer
2k
views
base64 hash using HMAC SHA256
I am trying to compute the Apex equivalent of the following -
var shaBodyContent = CryptoJS.HmacSHA256(stringToSign, postman.getEnvironmentVariable("HMAC_SS"));
var b64BodyContent = shaBodyContent....
4
votes
1
answer
3k
views
Encrypting and/or decrypting ciphertext with the provided Initialization Vector (IV)
I had given an cipher text (of JSON string), an IV and a key. I tried decrypting using Apex Crypto class's method:
decryptWithManagedIV(algorithmName, privateKey, IVAndCipherText)
//Sample code
...
2
votes
1
answer
2k
views
How can we encrypt/decrypt AES-GCM (A256GCM) algorithm (i.e. JCA: AES/GCM/NoPadding) in Salesforce?
I am currently working on a requirement where I am developing Apex REST callouts to an external data providers. Here the complexity lies within the encryption/decryption methods that they are using: ...
5
votes
0
answers
4k
views
Anonymous Crypto method error: last block incomplete in decryption
I am testing some Crypto methods for decryption in the anonymous window. But getting this error while trying with valid inputs:
Blob key = Blob.valueOf('xxxxxxxxxxxxxxxx');
System.debug('key: ' +key);...
1
vote
1
answer
148
views
How to add a generic method for Encryption and decryption when using multiple times in the code?
I am trying to encrypt two fields when record is submitted using VF page.
As there are multiple functions in my class I am encrypting and decrypting multiple times as needed. Is there a way we can ...
0
votes
0
answers
1k
views
System.SecurityException: last block incomplete in decryption
I'm getting the error when I'm trying to decrypt an encrypted value.
Using the standard method from Crypto Class : Encrypt and Decrypt
public static String encryptValue(String customKey,String ...
2
votes
2
answers
3k
views
Generate a JWT with HS256 signature
I am trying to generate an HS256 signed JWT token via Apex. I am using this token in the Authy registration process to enable 2FA for community users.
Per the Authy documentation HS256 is the only ...
1
vote
2
answers
942
views
Classic Master Encryption Keys in Apex
I'm using the Crypto class but want to leverage the built-in Master Encryption Key store instead of saving my own AES keys somewhere in the database. Is it possible to get access to the Master ...