github.com/mtsmfm/go/src@v0.0.0-20221020090648-44bdcb9f8fde/crypto/rsa/rsa_test.go (about)

     1  // Copyright 2009 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package rsa
     6  
     7  import (
     8  	"bytes"
     9  	"crypto"
    10  	"crypto/rand"
    11  	"crypto/sha1"
    12  	"crypto/sha256"
    13  	"fmt"
    14  	"math/big"
    15  	"testing"
    16  )
    17  
    18  import "crypto/internal/boring"
    19  
    20  func TestKeyGeneration(t *testing.T) {
    21  	for _, size := range []int{128, 1024, 2048, 3072} {
    22  		priv, err := GenerateKey(rand.Reader, size)
    23  		if err != nil {
    24  			t.Errorf("GenerateKey(%d): %v", size, err)
    25  		}
    26  		if bits := priv.N.BitLen(); bits != size {
    27  			t.Errorf("key too short (%d vs %d)", bits, size)
    28  		}
    29  		testKeyBasics(t, priv)
    30  		if testing.Short() {
    31  			break
    32  		}
    33  	}
    34  }
    35  
    36  func Test3PrimeKeyGeneration(t *testing.T) {
    37  	size := 768
    38  	if testing.Short() {
    39  		size = 256
    40  	}
    41  
    42  	priv, err := GenerateMultiPrimeKey(rand.Reader, 3, size)
    43  	if err != nil {
    44  		t.Errorf("failed to generate key")
    45  	}
    46  	testKeyBasics(t, priv)
    47  }
    48  
    49  func Test4PrimeKeyGeneration(t *testing.T) {
    50  	size := 768
    51  	if testing.Short() {
    52  		size = 256
    53  	}
    54  
    55  	priv, err := GenerateMultiPrimeKey(rand.Reader, 4, size)
    56  	if err != nil {
    57  		t.Errorf("failed to generate key")
    58  	}
    59  	testKeyBasics(t, priv)
    60  }
    61  
    62  func TestNPrimeKeyGeneration(t *testing.T) {
    63  	primeSize := 64
    64  	maxN := 24
    65  	if testing.Short() {
    66  		primeSize = 16
    67  		maxN = 16
    68  	}
    69  	// Test that generation of N-prime keys works for N > 4.
    70  	for n := 5; n < maxN; n++ {
    71  		priv, err := GenerateMultiPrimeKey(rand.Reader, n, 64+n*primeSize)
    72  		if err == nil {
    73  			testKeyBasics(t, priv)
    74  		} else {
    75  			t.Errorf("failed to generate %d-prime key", n)
    76  		}
    77  	}
    78  }
    79  
    80  func TestImpossibleKeyGeneration(t *testing.T) {
    81  	// This test ensures that trying to generate toy RSA keys doesn't enter
    82  	// an infinite loop.
    83  	for i := 0; i < 32; i++ {
    84  		GenerateKey(rand.Reader, i)
    85  		GenerateMultiPrimeKey(rand.Reader, 3, i)
    86  		GenerateMultiPrimeKey(rand.Reader, 4, i)
    87  		GenerateMultiPrimeKey(rand.Reader, 5, i)
    88  	}
    89  }
    90  
    91  func TestGnuTLSKey(t *testing.T) {
    92  	// This is a key generated by `certtool --generate-privkey --bits 128`.
    93  	// It's such that de ≢ 1 mod φ(n), but is congruent mod the order of
    94  	// the group.
    95  	priv := &PrivateKey{
    96  		PublicKey: PublicKey{
    97  			N: fromBase10("290684273230919398108010081414538931343"),
    98  			E: 65537,
    99  		},
   100  		D: fromBase10("31877380284581499213530787347443987241"),
   101  		Primes: []*big.Int{
   102  			fromBase10("16775196964030542637"),
   103  			fromBase10("17328218193455850539"),
   104  		},
   105  	}
   106  	testKeyBasics(t, priv)
   107  }
   108  
   109  func testKeyBasics(t *testing.T, priv *PrivateKey) {
   110  	if err := priv.Validate(); err != nil {
   111  		t.Errorf("Validate() failed: %s", err)
   112  	}
   113  	if priv.D.Cmp(priv.N) > 0 {
   114  		t.Errorf("private exponent too large")
   115  	}
   116  
   117  	if boring.Enabled {
   118  		// Cannot call encrypt/decrypt directly. Test via PKCS1v15.
   119  		msg := []byte("hi!")
   120  		enc, err := EncryptPKCS1v15(rand.Reader, &priv.PublicKey, msg)
   121  		if err != nil {
   122  			t.Errorf("EncryptPKCS1v15: %v", err)
   123  			return
   124  		}
   125  		dec, err := DecryptPKCS1v15(rand.Reader, priv, enc)
   126  		if err != nil {
   127  			t.Errorf("DecryptPKCS1v15: %v", err)
   128  			return
   129  		}
   130  		if !bytes.Equal(dec, msg) {
   131  			t.Errorf("got:%x want:%x (%+v)", dec, msg, priv)
   132  		}
   133  		return
   134  	}
   135  
   136  	pub := &priv.PublicKey
   137  	m := big.NewInt(42)
   138  	c := encrypt(new(big.Int), pub, m)
   139  
   140  	m2, err := decrypt(nil, priv, c)
   141  	if err != nil {
   142  		t.Errorf("error while decrypting: %s", err)
   143  		return
   144  	}
   145  	if m.Cmp(m2) != 0 {
   146  		t.Errorf("got:%v, want:%v (%+v)", m2, m, priv)
   147  	}
   148  
   149  	m3, err := decrypt(rand.Reader, priv, c)
   150  	if err != nil {
   151  		t.Errorf("error while decrypting (blind): %s", err)
   152  	}
   153  	if m.Cmp(m3) != 0 {
   154  		t.Errorf("(blind) got:%v, want:%v (%#v)", m3, m, priv)
   155  	}
   156  }
   157  
   158  func fromBase10(base10 string) *big.Int {
   159  	i, ok := new(big.Int).SetString(base10, 10)
   160  	if !ok {
   161  		panic("bad number: " + base10)
   162  	}
   163  	return i
   164  }
   165  
   166  var test2048Key *PrivateKey
   167  
   168  func init() {
   169  	test2048Key = &PrivateKey{
   170  		PublicKey: PublicKey{
   171  			N: fromBase10("14314132931241006650998084889274020608918049032671858325988396851334124245188214251956198731333464217832226406088020736932173064754214329009979944037640912127943488972644697423190955557435910767690712778463524983667852819010259499695177313115447116110358524558307947613422897787329221478860907963827160223559690523660574329011927531289655711860504630573766609239332569210831325633840174683944553667352219670930408593321661375473885147973879086994006440025257225431977751512374815915392249179976902953721486040787792801849818254465486633791826766873076617116727073077821584676715609985777563958286637185868165868520557"),
   172  			E: 3,
   173  		},
   174  		D: fromBase10("9542755287494004433998723259516013739278699355114572217325597900889416163458809501304132487555642811888150937392013824621448709836142886006653296025093941418628992648429798282127303704957273845127141852309016655778568546006839666463451542076964744073572349705538631742281931858219480985907271975884773482372966847639853897890615456605598071088189838676728836833012254065983259638538107719766738032720239892094196108713378822882383694456030043492571063441943847195939549773271694647657549658603365629458610273821292232646334717612674519997533901052790334279661754176490593041941863932308687197618671528035670452762731"),
   175  		Primes: []*big.Int{
   176  			fromBase10("130903255182996722426771613606077755295583329135067340152947172868415809027537376306193179624298874215608270802054347609836776473930072411958753044562214537013874103802006369634761074377213995983876788718033850153719421695468704276694983032644416930879093914927146648402139231293035971427838068945045019075433"),
   177  			fromBase10("109348945610485453577574767652527472924289229538286649661240938988020367005475727988253438647560958573506159449538793540472829815903949343191091817779240101054552748665267574271163617694640513549693841337820602726596756351006149518830932261246698766355347898158548465400674856021497190430791824869615170301029"),
   178  		},
   179  	}
   180  	test2048Key.Precompute()
   181  }
   182  
   183  func BenchmarkRSA2048Decrypt(b *testing.B) {
   184  	if boring.Enabled {
   185  		b.Skip("no raw decrypt in BoringCrypto")
   186  	}
   187  
   188  	b.StopTimer()
   189  
   190  	c := fromBase10("8472002792838218989464636159316973636630013835787202418124758118372358261975764365740026024610403138425986214991379012696600761514742817632790916315594342398720903716529235119816755589383377471752116975374952783629225022962092351886861518911824745188989071172097120352727368980275252089141512321893536744324822590480751098257559766328893767334861211872318961900897793874075248286439689249972315699410830094164386544311554704755110361048571142336148077772023880664786019636334369759624917224888206329520528064315309519262325023881707530002540634660750469137117568199824615333883758410040459705787022909848740188613313")
   191  
   192  	b.StartTimer()
   193  
   194  	for i := 0; i < b.N; i++ {
   195  		decrypt(nil, test2048Key, c)
   196  	}
   197  }
   198  
   199  func BenchmarkRSA2048Sign(b *testing.B) {
   200  	b.StopTimer()
   201  	hashed := sha256.Sum256([]byte("testing"))
   202  	b.StartTimer()
   203  
   204  	for i := 0; i < b.N; i++ {
   205  		SignPKCS1v15(rand.Reader, test2048Key, crypto.SHA256, hashed[:])
   206  	}
   207  }
   208  
   209  func Benchmark3PrimeRSA2048Decrypt(b *testing.B) {
   210  	if boring.Enabled {
   211  		b.Skip("no raw decrypt in BoringCrypto")
   212  	}
   213  
   214  	b.StopTimer()
   215  	priv := &PrivateKey{
   216  		PublicKey: PublicKey{
   217  			N: fromBase10("16346378922382193400538269749936049106320265317511766357599732575277382844051791096569333808598921852351577762718529818072849191122419410612033592401403764925096136759934497687765453905884149505175426053037420486697072448609022753683683718057795566811401938833367954642951433473337066311978821180526439641496973296037000052546108507805269279414789035461158073156772151892452251106173507240488993608650881929629163465099476849643165682709047462010581308719577053905787496296934240246311806555924593059995202856826239801816771116902778517096212527979497399966526283516447337775509777558018145573127308919204297111496233"),
   218  			E: 3,
   219  		},
   220  		D: fromBase10("10897585948254795600358846499957366070880176878341177571733155050184921896034527397712889205732614568234385175145686545381899460748279607074689061600935843283397424506622998458510302603922766336783617368686090042765718290914099334449154829375179958369993407724946186243249568928237086215759259909861748642124071874879861299389874230489928271621259294894142840428407196932444474088857746123104978617098858619445675532587787023228852383149557470077802718705420275739737958953794088728369933811184572620857678792001136676902250566845618813972833750098806496641114644760255910789397593428910198080271317419213080834885003"),
   221  		Primes: []*big.Int{
   222  			fromBase10("1025363189502892836833747188838978207017355117492483312747347695538428729137306368764177201532277413433182799108299960196606011786562992097313508180436744488171474690412562218914213688661311117337381958560443"),
   223  			fromBase10("3467903426626310123395340254094941045497208049900750380025518552334536945536837294961497712862519984786362199788654739924501424784631315081391467293694361474867825728031147665777546570788493758372218019373"),
   224  			fromBase10("4597024781409332673052708605078359346966325141767460991205742124888960305710298765592730135879076084498363772408626791576005136245060321874472727132746643162385746062759369754202494417496879741537284589047"),
   225  		},
   226  	}
   227  	priv.Precompute()
   228  
   229  	c := fromBase10("8472002792838218989464636159316973636630013835787202418124758118372358261975764365740026024610403138425986214991379012696600761514742817632790916315594342398720903716529235119816755589383377471752116975374952783629225022962092351886861518911824745188989071172097120352727368980275252089141512321893536744324822590480751098257559766328893767334861211872318961900897793874075248286439689249972315699410830094164386544311554704755110361048571142336148077772023880664786019636334369759624917224888206329520528064315309519262325023881707530002540634660750469137117568199824615333883758410040459705787022909848740188613313")
   230  
   231  	b.StartTimer()
   232  
   233  	for i := 0; i < b.N; i++ {
   234  		decrypt(nil, priv, c)
   235  	}
   236  }
   237  
   238  type testEncryptOAEPMessage struct {
   239  	in   []byte
   240  	seed []byte
   241  	out  []byte
   242  }
   243  
   244  type testEncryptOAEPStruct struct {
   245  	modulus string
   246  	e       int
   247  	d       string
   248  	msgs    []testEncryptOAEPMessage
   249  }
   250  
   251  func TestEncryptOAEP(t *testing.T) {
   252  	sha1 := sha1.New()
   253  	n := new(big.Int)
   254  	for i, test := range testEncryptOAEPData {
   255  		n.SetString(test.modulus, 16)
   256  		public := PublicKey{N: n, E: test.e}
   257  
   258  		for j, message := range test.msgs {
   259  			randomSource := bytes.NewReader(message.seed)
   260  			out, err := EncryptOAEP(sha1, randomSource, &public, message.in, nil)
   261  			if err != nil {
   262  				t.Errorf("#%d,%d error: %s", i, j, err)
   263  			}
   264  			if !bytes.Equal(out, message.out) {
   265  				t.Errorf("#%d,%d bad result: %x (want %x)", i, j, out, message.out)
   266  			}
   267  		}
   268  	}
   269  }
   270  
   271  func TestDecryptOAEP(t *testing.T) {
   272  	random := rand.Reader
   273  
   274  	sha1 := sha1.New()
   275  	n := new(big.Int)
   276  	d := new(big.Int)
   277  	for i, test := range testEncryptOAEPData {
   278  		n.SetString(test.modulus, 16)
   279  		d.SetString(test.d, 16)
   280  		private := new(PrivateKey)
   281  		private.PublicKey = PublicKey{N: n, E: test.e}
   282  		private.D = d
   283  
   284  		for j, message := range test.msgs {
   285  			out, err := DecryptOAEP(sha1, nil, private, message.out, nil)
   286  			if err != nil {
   287  				t.Errorf("#%d,%d error: %s", i, j, err)
   288  			} else if !bytes.Equal(out, message.in) {
   289  				t.Errorf("#%d,%d bad result: %#v (want %#v)", i, j, out, message.in)
   290  			}
   291  
   292  			// Decrypt with blinding.
   293  			out, err = DecryptOAEP(sha1, random, private, message.out, nil)
   294  			if err != nil {
   295  				t.Errorf("#%d,%d (blind) error: %s", i, j, err)
   296  			} else if !bytes.Equal(out, message.in) {
   297  				t.Errorf("#%d,%d (blind) bad result: %#v (want %#v)", i, j, out, message.in)
   298  			}
   299  		}
   300  		if testing.Short() {
   301  			break
   302  		}
   303  	}
   304  }
   305  
   306  func TestEncryptDecryptOAEP(t *testing.T) {
   307  	sha256 := sha256.New()
   308  	n := new(big.Int)
   309  	d := new(big.Int)
   310  	for i, test := range testEncryptOAEPData {
   311  		n.SetString(test.modulus, 16)
   312  		d.SetString(test.d, 16)
   313  		priv := new(PrivateKey)
   314  		priv.PublicKey = PublicKey{N: n, E: test.e}
   315  		priv.D = d
   316  
   317  		for j, message := range test.msgs {
   318  			label := []byte(fmt.Sprintf("hi#%d", j))
   319  			enc, err := EncryptOAEP(sha256, rand.Reader, &priv.PublicKey, message.in, label)
   320  			if err != nil {
   321  				t.Errorf("#%d,%d: EncryptOAEP: %v", i, j, err)
   322  				continue
   323  			}
   324  			dec, err := DecryptOAEP(sha256, rand.Reader, priv, enc, label)
   325  			if err != nil {
   326  				t.Errorf("#%d,%d: DecryptOAEP: %v", i, j, err)
   327  				continue
   328  			}
   329  			if !bytes.Equal(dec, message.in) {
   330  				t.Errorf("#%d,%d: round trip %q -> %q", i, j, message.in, dec)
   331  			}
   332  		}
   333  	}
   334  }
   335  
   336  // testEncryptOAEPData contains a subset of the vectors from RSA's "Test vectors for RSA-OAEP".
   337  var testEncryptOAEPData = []testEncryptOAEPStruct{
   338  	// Key 1
   339  	{"a8b3b284af8eb50b387034a860f146c4919f318763cd6c5598c8ae4811a1e0abc4c7e0b082d693a5e7fced675cf4668512772c0cbc64a742c6c630f533c8cc72f62ae833c40bf25842e984bb78bdbf97c0107d55bdb662f5c4e0fab9845cb5148ef7392dd3aaff93ae1e6b667bb3d4247616d4f5ba10d4cfd226de88d39f16fb",
   340  		65537,
   341  		"53339cfdb79fc8466a655c7316aca85c55fd8f6dd898fdaf119517ef4f52e8fd8e258df93fee180fa0e4ab29693cd83b152a553d4ac4d1812b8b9fa5af0e7f55fe7304df41570926f3311f15c4d65a732c483116ee3d3d2d0af3549ad9bf7cbfb78ad884f84d5beb04724dc7369b31def37d0cf539e9cfcdd3de653729ead5d1",
   342  		[]testEncryptOAEPMessage{
   343  			// Example 1.1
   344  			{
   345  				[]byte{0x66, 0x28, 0x19, 0x4e, 0x12, 0x07, 0x3d, 0xb0,
   346  					0x3b, 0xa9, 0x4c, 0xda, 0x9e, 0xf9, 0x53, 0x23, 0x97,
   347  					0xd5, 0x0d, 0xba, 0x79, 0xb9, 0x87, 0x00, 0x4a, 0xfe,
   348  					0xfe, 0x34,
   349  				},
   350  				[]byte{0x18, 0xb7, 0x76, 0xea, 0x21, 0x06, 0x9d, 0x69,
   351  					0x77, 0x6a, 0x33, 0xe9, 0x6b, 0xad, 0x48, 0xe1, 0xdd,
   352  					0xa0, 0xa5, 0xef,
   353  				},
   354  				[]byte{0x35, 0x4f, 0xe6, 0x7b, 0x4a, 0x12, 0x6d, 0x5d,
   355  					0x35, 0xfe, 0x36, 0xc7, 0x77, 0x79, 0x1a, 0x3f, 0x7b,
   356  					0xa1, 0x3d, 0xef, 0x48, 0x4e, 0x2d, 0x39, 0x08, 0xaf,
   357  					0xf7, 0x22, 0xfa, 0xd4, 0x68, 0xfb, 0x21, 0x69, 0x6d,
   358  					0xe9, 0x5d, 0x0b, 0xe9, 0x11, 0xc2, 0xd3, 0x17, 0x4f,
   359  					0x8a, 0xfc, 0xc2, 0x01, 0x03, 0x5f, 0x7b, 0x6d, 0x8e,
   360  					0x69, 0x40, 0x2d, 0xe5, 0x45, 0x16, 0x18, 0xc2, 0x1a,
   361  					0x53, 0x5f, 0xa9, 0xd7, 0xbf, 0xc5, 0xb8, 0xdd, 0x9f,
   362  					0xc2, 0x43, 0xf8, 0xcf, 0x92, 0x7d, 0xb3, 0x13, 0x22,
   363  					0xd6, 0xe8, 0x81, 0xea, 0xa9, 0x1a, 0x99, 0x61, 0x70,
   364  					0xe6, 0x57, 0xa0, 0x5a, 0x26, 0x64, 0x26, 0xd9, 0x8c,
   365  					0x88, 0x00, 0x3f, 0x84, 0x77, 0xc1, 0x22, 0x70, 0x94,
   366  					0xa0, 0xd9, 0xfa, 0x1e, 0x8c, 0x40, 0x24, 0x30, 0x9c,
   367  					0xe1, 0xec, 0xcc, 0xb5, 0x21, 0x00, 0x35, 0xd4, 0x7a,
   368  					0xc7, 0x2e, 0x8a,
   369  				},
   370  			},
   371  			// Example 1.2
   372  			{
   373  				[]byte{0x75, 0x0c, 0x40, 0x47, 0xf5, 0x47, 0xe8, 0xe4,
   374  					0x14, 0x11, 0x85, 0x65, 0x23, 0x29, 0x8a, 0xc9, 0xba,
   375  					0xe2, 0x45, 0xef, 0xaf, 0x13, 0x97, 0xfb, 0xe5, 0x6f,
   376  					0x9d, 0xd5,
   377  				},
   378  				[]byte{0x0c, 0xc7, 0x42, 0xce, 0x4a, 0x9b, 0x7f, 0x32,
   379  					0xf9, 0x51, 0xbc, 0xb2, 0x51, 0xef, 0xd9, 0x25, 0xfe,
   380  					0x4f, 0xe3, 0x5f,
   381  				},
   382  				[]byte{0x64, 0x0d, 0xb1, 0xac, 0xc5, 0x8e, 0x05, 0x68,
   383  					0xfe, 0x54, 0x07, 0xe5, 0xf9, 0xb7, 0x01, 0xdf, 0xf8,
   384  					0xc3, 0xc9, 0x1e, 0x71, 0x6c, 0x53, 0x6f, 0xc7, 0xfc,
   385  					0xec, 0x6c, 0xb5, 0xb7, 0x1c, 0x11, 0x65, 0x98, 0x8d,
   386  					0x4a, 0x27, 0x9e, 0x15, 0x77, 0xd7, 0x30, 0xfc, 0x7a,
   387  					0x29, 0x93, 0x2e, 0x3f, 0x00, 0xc8, 0x15, 0x15, 0x23,
   388  					0x6d, 0x8d, 0x8e, 0x31, 0x01, 0x7a, 0x7a, 0x09, 0xdf,
   389  					0x43, 0x52, 0xd9, 0x04, 0xcd, 0xeb, 0x79, 0xaa, 0x58,
   390  					0x3a, 0xdc, 0xc3, 0x1e, 0xa6, 0x98, 0xa4, 0xc0, 0x52,
   391  					0x83, 0xda, 0xba, 0x90, 0x89, 0xbe, 0x54, 0x91, 0xf6,
   392  					0x7c, 0x1a, 0x4e, 0xe4, 0x8d, 0xc7, 0x4b, 0xbb, 0xe6,
   393  					0x64, 0x3a, 0xef, 0x84, 0x66, 0x79, 0xb4, 0xcb, 0x39,
   394  					0x5a, 0x35, 0x2d, 0x5e, 0xd1, 0x15, 0x91, 0x2d, 0xf6,
   395  					0x96, 0xff, 0xe0, 0x70, 0x29, 0x32, 0x94, 0x6d, 0x71,
   396  					0x49, 0x2b, 0x44,
   397  				},
   398  			},
   399  			// Example 1.3
   400  			{
   401  				[]byte{0xd9, 0x4a, 0xe0, 0x83, 0x2e, 0x64, 0x45, 0xce,
   402  					0x42, 0x33, 0x1c, 0xb0, 0x6d, 0x53, 0x1a, 0x82, 0xb1,
   403  					0xdb, 0x4b, 0xaa, 0xd3, 0x0f, 0x74, 0x6d, 0xc9, 0x16,
   404  					0xdf, 0x24, 0xd4, 0xe3, 0xc2, 0x45, 0x1f, 0xff, 0x59,
   405  					0xa6, 0x42, 0x3e, 0xb0, 0xe1, 0xd0, 0x2d, 0x4f, 0xe6,
   406  					0x46, 0xcf, 0x69, 0x9d, 0xfd, 0x81, 0x8c, 0x6e, 0x97,
   407  					0xb0, 0x51,
   408  				},
   409  				[]byte{0x25, 0x14, 0xdf, 0x46, 0x95, 0x75, 0x5a, 0x67,
   410  					0xb2, 0x88, 0xea, 0xf4, 0x90, 0x5c, 0x36, 0xee, 0xc6,
   411  					0x6f, 0xd2, 0xfd,
   412  				},
   413  				[]byte{0x42, 0x37, 0x36, 0xed, 0x03, 0x5f, 0x60, 0x26,
   414  					0xaf, 0x27, 0x6c, 0x35, 0xc0, 0xb3, 0x74, 0x1b, 0x36,
   415  					0x5e, 0x5f, 0x76, 0xca, 0x09, 0x1b, 0x4e, 0x8c, 0x29,
   416  					0xe2, 0xf0, 0xbe, 0xfe, 0xe6, 0x03, 0x59, 0x5a, 0xa8,
   417  					0x32, 0x2d, 0x60, 0x2d, 0x2e, 0x62, 0x5e, 0x95, 0xeb,
   418  					0x81, 0xb2, 0xf1, 0xc9, 0x72, 0x4e, 0x82, 0x2e, 0xca,
   419  					0x76, 0xdb, 0x86, 0x18, 0xcf, 0x09, 0xc5, 0x34, 0x35,
   420  					0x03, 0xa4, 0x36, 0x08, 0x35, 0xb5, 0x90, 0x3b, 0xc6,
   421  					0x37, 0xe3, 0x87, 0x9f, 0xb0, 0x5e, 0x0e, 0xf3, 0x26,
   422  					0x85, 0xd5, 0xae, 0xc5, 0x06, 0x7c, 0xd7, 0xcc, 0x96,
   423  					0xfe, 0x4b, 0x26, 0x70, 0xb6, 0xea, 0xc3, 0x06, 0x6b,
   424  					0x1f, 0xcf, 0x56, 0x86, 0xb6, 0x85, 0x89, 0xaa, 0xfb,
   425  					0x7d, 0x62, 0x9b, 0x02, 0xd8, 0xf8, 0x62, 0x5c, 0xa3,
   426  					0x83, 0x36, 0x24, 0xd4, 0x80, 0x0f, 0xb0, 0x81, 0xb1,
   427  					0xcf, 0x94, 0xeb,
   428  				},
   429  			},
   430  		},
   431  	},
   432  	// Key 10
   433  	{"ae45ed5601cec6b8cc05f803935c674ddbe0d75c4c09fd7951fc6b0caec313a8df39970c518bffba5ed68f3f0d7f22a4029d413f1ae07e4ebe9e4177ce23e7f5404b569e4ee1bdcf3c1fb03ef113802d4f855eb9b5134b5a7c8085adcae6fa2fa1417ec3763be171b0c62b760ede23c12ad92b980884c641f5a8fac26bdad4a03381a22fe1b754885094c82506d4019a535a286afeb271bb9ba592de18dcf600c2aeeae56e02f7cf79fc14cf3bdc7cd84febbbf950ca90304b2219a7aa063aefa2c3c1980e560cd64afe779585b6107657b957857efde6010988ab7de417fc88d8f384c4e6e72c3f943e0c31c0c4a5cc36f879d8a3ac9d7d59860eaada6b83bb",
   434  		65537,
   435  		"056b04216fe5f354ac77250a4b6b0c8525a85c59b0bd80c56450a22d5f438e596a333aa875e291dd43f48cb88b9d5fc0d499f9fcd1c397f9afc070cd9e398c8d19e61db7c7410a6b2675dfbf5d345b804d201add502d5ce2dfcb091ce9997bbebe57306f383e4d588103f036f7e85d1934d152a323e4a8db451d6f4a5b1b0f102cc150e02feee2b88dea4ad4c1baccb24d84072d14e1d24a6771f7408ee30564fb86d4393a34bcf0b788501d193303f13a2284b001f0f649eaf79328d4ac5c430ab4414920a9460ed1b7bc40ec653e876d09abc509ae45b525190116a0c26101848298509c1c3bf3a483e7274054e15e97075036e989f60932807b5257751e79",
   436  		[]testEncryptOAEPMessage{
   437  			// Example 10.1
   438  			{
   439  				[]byte{0x8b, 0xba, 0x6b, 0xf8, 0x2a, 0x6c, 0x0f, 0x86,
   440  					0xd5, 0xf1, 0x75, 0x6e, 0x97, 0x95, 0x68, 0x70, 0xb0,
   441  					0x89, 0x53, 0xb0, 0x6b, 0x4e, 0xb2, 0x05, 0xbc, 0x16,
   442  					0x94, 0xee,
   443  				},
   444  				[]byte{0x47, 0xe1, 0xab, 0x71, 0x19, 0xfe, 0xe5, 0x6c,
   445  					0x95, 0xee, 0x5e, 0xaa, 0xd8, 0x6f, 0x40, 0xd0, 0xaa,
   446  					0x63, 0xbd, 0x33,
   447  				},
   448  				[]byte{0x53, 0xea, 0x5d, 0xc0, 0x8c, 0xd2, 0x60, 0xfb,
   449  					0x3b, 0x85, 0x85, 0x67, 0x28, 0x7f, 0xa9, 0x15, 0x52,
   450  					0xc3, 0x0b, 0x2f, 0xeb, 0xfb, 0xa2, 0x13, 0xf0, 0xae,
   451  					0x87, 0x70, 0x2d, 0x06, 0x8d, 0x19, 0xba, 0xb0, 0x7f,
   452  					0xe5, 0x74, 0x52, 0x3d, 0xfb, 0x42, 0x13, 0x9d, 0x68,
   453  					0xc3, 0xc5, 0xaf, 0xee, 0xe0, 0xbf, 0xe4, 0xcb, 0x79,
   454  					0x69, 0xcb, 0xf3, 0x82, 0xb8, 0x04, 0xd6, 0xe6, 0x13,
   455  					0x96, 0x14, 0x4e, 0x2d, 0x0e, 0x60, 0x74, 0x1f, 0x89,
   456  					0x93, 0xc3, 0x01, 0x4b, 0x58, 0xb9, 0xb1, 0x95, 0x7a,
   457  					0x8b, 0xab, 0xcd, 0x23, 0xaf, 0x85, 0x4f, 0x4c, 0x35,
   458  					0x6f, 0xb1, 0x66, 0x2a, 0xa7, 0x2b, 0xfc, 0xc7, 0xe5,
   459  					0x86, 0x55, 0x9d, 0xc4, 0x28, 0x0d, 0x16, 0x0c, 0x12,
   460  					0x67, 0x85, 0xa7, 0x23, 0xeb, 0xee, 0xbe, 0xff, 0x71,
   461  					0xf1, 0x15, 0x94, 0x44, 0x0a, 0xae, 0xf8, 0x7d, 0x10,
   462  					0x79, 0x3a, 0x87, 0x74, 0xa2, 0x39, 0xd4, 0xa0, 0x4c,
   463  					0x87, 0xfe, 0x14, 0x67, 0xb9, 0xda, 0xf8, 0x52, 0x08,
   464  					0xec, 0x6c, 0x72, 0x55, 0x79, 0x4a, 0x96, 0xcc, 0x29,
   465  					0x14, 0x2f, 0x9a, 0x8b, 0xd4, 0x18, 0xe3, 0xc1, 0xfd,
   466  					0x67, 0x34, 0x4b, 0x0c, 0xd0, 0x82, 0x9d, 0xf3, 0xb2,
   467  					0xbe, 0xc6, 0x02, 0x53, 0x19, 0x62, 0x93, 0xc6, 0xb3,
   468  					0x4d, 0x3f, 0x75, 0xd3, 0x2f, 0x21, 0x3d, 0xd4, 0x5c,
   469  					0x62, 0x73, 0xd5, 0x05, 0xad, 0xf4, 0xcc, 0xed, 0x10,
   470  					0x57, 0xcb, 0x75, 0x8f, 0xc2, 0x6a, 0xee, 0xfa, 0x44,
   471  					0x12, 0x55, 0xed, 0x4e, 0x64, 0xc1, 0x99, 0xee, 0x07,
   472  					0x5e, 0x7f, 0x16, 0x64, 0x61, 0x82, 0xfd, 0xb4, 0x64,
   473  					0x73, 0x9b, 0x68, 0xab, 0x5d, 0xaf, 0xf0, 0xe6, 0x3e,
   474  					0x95, 0x52, 0x01, 0x68, 0x24, 0xf0, 0x54, 0xbf, 0x4d,
   475  					0x3c, 0x8c, 0x90, 0xa9, 0x7b, 0xb6, 0xb6, 0x55, 0x32,
   476  					0x84, 0xeb, 0x42, 0x9f, 0xcc,
   477  				},
   478  			},
   479  		},
   480  	},
   481  }