# Public-Key Cryptography

Public-key cryptography uses mathematically related public and private keys to support encryption, digital signatures, and secure key establishment.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/public-key-cryptography

> A public key can be distributed, while its corresponding private key must remain secret and under its owner's control. This separation enables cloud systems to authenticate servers and users, establish encrypted connections, and verify signed data without sharing a single secret with every participant.

Practice exams covering Public-Key Cryptography: [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate).

## 6 key aspects of Public-Key Cryptography

Public-key cryptography depends on protected private keys, authentic public keys, appropriate algorithms, and correctly managed trust relationships.

1. **Separate public and private keys**: Distribute public keys as needed, but restrict access to private keys. Public keys are not confidential, yet their authenticity must be verified before trusting them.
2. **Algorithm-specific capabilities**: Choose algorithms according to the required operation: encryption, signing, or key agreement. Do not assume that every asymmetric key type supports all three.
3. **Certificates bind keys to identities**: Certificates associate a public key with an identity through an issuer's signature. Correct validation requires a trusted chain and checks such as hostname matching and expiration.
4. **Proof of private-key possession**: TLS and SSH use cryptographic proofs to establish that a peer controls its private key without transmitting that key. SSH user authentication and SSH server host authentication are separate checks.
5. **Hybrid encryption for efficiency**: Protocols typically use asymmetric operations to authenticate peers and establish secrets, then symmetric encryption to protect bulk data. This avoids the performance and message-size limitations of direct asymmetric encryption.
6. **Key and trust lifecycle management**: Protect private keys with appropriate storage, permissions, and access controls, and renew certificates before expiration. After compromise, replace keys and remove or revoke the old trust relationships wherever they remain valid.

## Cloud services for Public-Key Cryptography

These services address different parts of public-key operations. EC2 applies SSH key pairs to instance access, while ACM manages TLS certificates for supported application endpoints. AWS Private CA supplies certificates for internal trust domains, which require explicit trust configuration on clients. AWS KMS provides protected asymmetric operations for application workflows without distributing private keys. A development environment might use a locally generated SSH key for EC2 access and an ACM-managed certificate for its HTTPS endpoint. Keep these credentials separate: an SSH key pair, a TLS certificate and private key, and a KMS key serve different purposes and are not interchangeable.

- **[Amazon EC2](https://blowstack.com/tools/cloud-services-hub/amazon-ec2)**: EC2 key pairs support SSH access to Linux instances by placing the public key on the instance while the client retains the private key. You can import a locally generated public key; EC2-generated private key material is available for download only when the key pair is created.
- **[AWS Private Certificate Authority](https://blowstack.com/tools/cloud-services-hub/aws-private-certificate-authority)**: AWS Private CA issues certificates under a private certificate hierarchy for internal identities and endpoints. Clients must explicitly trust the appropriate private CA; these certificates are not automatically trusted by public browsers.

## Public-Key Cryptography exam questions

Real practice exam questions on Public-Key Cryptography, with the correct answer and its explanation.

### Question 1 (DVA-C02)

**Question:**

A developer is automating the launch of temporary Amazon Linux EC2 instances in two AWS Regions. The developer must use the same SSH key pair to connect to every instance. Company policy requires that the private key be generated on the developer's laptop and never uploaded to AWS. The instances use a standard Amazon Linux AMI with no preconfigured developer access. Which solution meets these requirements?

**Correct answer:** Generate an RSA SSH key pair on the laptop. Import the public key into EC2 in each Region, and specify the corresponding Regional key pair when launching each instance. Keep the private key on the laptop with restrictive file permissions.

**Explanation:** EC2 supports importing an existing public SSH key. Key pair resources are Regional, so the public key must be imported into both Regions. At launch, Amazon Linux places the selected public key in the default user's authorized_keys file. The developer authenticates with the private key, which remains on the laptop.

## Practice Public-Key Cryptography in a full exam

Questions on Public-Key Cryptography in each practice exam, with every answer option and an explanation for each:

- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 1 question

## What is Public-Key Cryptography

Public-key cryptography, also called asymmetric cryptography, uses a pair of mathematically related keys. Disclosing the public key should not make deriving the private key computationally feasible when appropriate algorithms and key sizes are used. Depending on the algorithm, the pair supports encryption, digital signatures, or key agreement. These operations are distinct: RSA can support encryption and signatures through different schemes, while Ed25519 is a signature algorithm, not an encryption algorithm.

For confidentiality, an appropriate encryption scheme allows someone to encrypt data with the recipient's public key so that only the corresponding private key can decrypt it. For signatures, the private key signs data and the public key verifies the signature. A signature provides integrity and evidence that the signer controls the private key; it does not hide the signed data. Describing signing as simply encrypting with a private key is misleading and does not accurately describe modern signature schemes.

Cloud connections typically combine asymmetric and symmetric cryptography. During a modern TLS handshake, certificates and signatures authenticate the server, while key agreement establishes shared secrets from which symmetric traffic keys are derived. Symmetric encryption then protects application traffic efficiently. Public-key cryptography is generally not used to encrypt large application payloads directly because it is more computationally expensive and, for encryption schemes such as RSA-OAEP, has strict message-size limits.

A certificate binds a public key to an identity through an issuer's signature. An X.509 server certificate includes identity information, validity dates, and extensions such as subject alternative names. Clients must validate the certificate chain, validity period, intended usage, and requested hostname. Possessing a certificate alone does not prove ownership: the server must also demonstrate control of the corresponding private key. A certificate signing request contains the public key and requested identity information, not the private key.

For a local HTTPS development endpoint, OpenSSL can generate a private key and a self-signed certificate. For example, run openssl req -x509 -newkey rsa:3072 -sha256 -days 7 -keyout dev.key -out dev.crt -subj '/CN=localhost' -addext 'subjectAltName=DNS:localhost'. This command prompts for a passphrase to protect the private key. A self-signed certificate is not automatically trusted by browsers or other clients; explicitly configure trust in the development environment rather than disabling certificate validation. For teams, a dedicated development certificate authority can provide a more manageable trust model.

SSH uses public-key cryptography for authentication without requiring an X.509 certificate. Generate a development key pair with ssh-keygen -t ed25519 -f ~/.ssh/dev\_ed25519 and choose a passphrase. Install only the .pub file's contents in the target user's authorized\_keys file, and keep the private key on the client with restrictive permissions, such as chmod 600 ~/.ssh/dev\_ed25519. SSH authentication proves possession through a signature; it does not send the private key to the server. Verify the server's host-key fingerprint separately to avoid connecting to an impostor.

In cloud environments, certificate managers automate certificate issuance and deployment, virtual machines accept SSH public keys, and managed key services protect asymmetric private keys for signing or decryption. Keep development and production keys separate, never commit private keys to source control, and plan certificate renewal and key replacement. A passphrase protects a stored private-key file but does not eliminate risk after the key is unlocked. Replacing a compromised SSH key also requires removing its old public key from every authorized location; issuing a new pair alone does not revoke access.
