rsaoaep

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

README

pki/rsaoaep

Import path: github.com/InsideGallery/core/pki/rsaoaep

rsaoaep is the preferred RSA-OAEP import path. It re-exports the legacy pki/rsa implementation with names that avoid a local collision with Go's standard crypto/rsa package.

Main API

  • Cipher is an alias for the legacy RSA-OAEP cipher type.
  • New(bits) generates a new RSA private key and matching public key.
  • FromPrivateKey(data) restores a cipher from PKCS#1 private-key PEM data.
  • DefaultKeyBits is the default key size, currently 4096 bits.
  • PrivateKeyPEMBlockType is the PEM block type used by ToBinary.
  • ErrFailedToParsePEMBlock reports data that is not a private-key PEM block.
  • Cipher.Encrypt, Cipher.Decrypt, Cipher.Kind, Cipher.ToBinary, and Cipher.FromBinary are inherited from pki/rsa.

Usage

package example

import "github.com/InsideGallery/core/pki/rsaoaep"

func restoreAndDecrypt(privateKeyPEM, ciphertext []byte) ([]byte, error) {
	cipher, err := rsaoaep.FromPrivateKey(privateKeyPEM)
	if err != nil {
		return nil, err
	}

	return cipher.Decrypt(ciphertext)
}

Security and Compatibility Notes

Encryption uses RSA-OAEP with SHA-256 and a nil label. RSA-OAEP is suited to short payloads such as wrapped keys. github.com/InsideGallery/core/pki/rsa remains available for existing consumers, but new code should import this package.

Documentation

Overview

Package rsaoaep provides RSA-OAEP cipher helpers without colliding with crypto/rsa.

New code should import this package instead of the legacy pki/rsa path:

import "github.com/InsideGallery/core/pki/rsaoaep"

Compatibility: github.com/InsideGallery/core/pki/rsa remains available for existing consumers. Prefer New and FromPrivateKey from rsaoaep so RSA-OAEP usage has an algorithm-specific import path.

Index

Constants

View Source
const (
	// PrivateKeyPEMBlockType is the PEM block type used for PKCS#1 private keys.
	PrivateKeyPEMBlockType = legacy.TypeRSAPrivateKey
	// DefaultKeyBits is the default RSA key size.
	DefaultKeyBits = legacy.DefaultBitsSize
)

Variables

View Source
var ErrFailedToParsePEMBlock = legacy.ErrFailedToParsePEMBlock

ErrFailedToParsePEMBlock reports invalid private-key PEM data.

Functions

This section is empty.

Types

type Cipher

type Cipher = legacy.RSA

Cipher encrypts and decrypts data with RSA-OAEP.

func FromPrivateKey

func FromPrivateKey(data []byte) (*Cipher, error)

FromPrivateKey restores an RSA-OAEP cipher from PKCS#1 private-key PEM data.

func New

func New(bits int) (*Cipher, error)

New returns an RSA-OAEP cipher with a randomly generated key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL