1// Copyright (C) 2023 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15package main 16 17import ( 18 "android.com/libcore/certutil" 19 "crypto/x509" 20 "path/filepath" 21) 22 23// Build the required certs for X509CertChainBuildingTest. 24// See that class for the requirements. 25func main() { 26 a := certutil.NewCA("Root A") 27 b := certutil.NewCA("Root B") 28 intermediate := certutil.NewCA("intermediate") 29 leaf1 := certutil.NewEntity("Leaf") 30 leaf2 := certutil.NewEntity("Leaf 2") 31 32 outdir := "assets/path_building/" 33 a.SignToPEM(a, filepath.Join(outdir, "a")) 34 a.SignWithAlgorithmToPEM(a, x509.ECDSAWithSHA1, filepath.Join(outdir, "a_sha1")) 35 b.SignToPEM(b, filepath.Join(outdir, "b")) 36 37 a.SignToPEM(b, filepath.Join(outdir, "b_to_a")) 38 b.SignToPEM(a, filepath.Join(outdir, "a_to_b")) 39 40 a.SignToPEM(leaf1, filepath.Join(outdir, "leaf1")) 41 42 a.SignToPEM(intermediate, filepath.Join(outdir, "intermediate_a")) 43 b.SignToPEM(intermediate, filepath.Join(outdir, "intermediate_b")) 44 45 intermediate.SignToPEM(leaf2, outdir+"leaf2") 46} 47